• BunnyBoy
  • NEWBIE
  • 25 Points
  • Member since 2008

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 11
    Replies
Hi. I have created a custom object (Enquiry__c) and when this object is created or updated I want it to create or update a Contact record. I have added a custom lookup field to the Contact object that captures the Enquiry__c unique ID.

I have got the creating part of the trigger working but am struggling on the update. If I try to update an Enquiry__c record I get an error message "MISSING_ARGUMENT, Id not specified in an update call". I realise I must need to locate the ID for the relevant Contact record but have not worked out how to do this. Following is my code:

Code:
trigger enquiryInsertContact on Enquiry__c (after insert, before update) {
List<Contact> contacts = new Contact[0];
if (Trigger.isInsert) {
 for (Enquiry__c enq : Trigger.new) {
  contacts.add(new Contact (FirstName = enq.Enquiry_First_Name__c,
     LastName = enq.Enquiry_Surname__c,
     Salutation = enq.Salutation__c));
  }
 insert contacts;
 }
else if (Trigger.isUpdate) {
 for (Enquiry__c enq : Trigger.new) {
  contacts.add(new Contact (FirstName = enq.Enquiry_First_Name__c));
  }
 update contacts;
 }
}

 If anybody coudl point me in the right direction it would be greatly appreciated.

Cheers.

I am not seeing where Profiles can be imported.  Is there a way?
Hi All,
 
I am facing an issue when i try to update the record type id for the case records to change the page layout.
i have two different pagelayouts.one for migrated cases and the other for salesforce cases. there are some migrated cases that are having a different layout then desired. so i tried to change the record type id value to the migrated record type, so that the page layout will be updated to migrated one.
 
But it is not updating and at the same time no errors are reported in the data loader.
Can some one pls help me in this.
 
Regards,
Udaya
Hi all,
 
the problem is as follows:
I need to set up a workflow that creates two tasks if these rules match:
- opportunity stage has a certain value
- The opportunity has at least one product with a certain "product code"
 
Now our internal work procedure requires us to first add new products to the opportunity and then switch the opportunity stage to the desired "trigger value" that should fire the workflow.
 
Option A:
Chose "Opportunity" as workflow trigger object. The show stopper is that its not possible to use opportunity products in the workflow rules - their fields are simply not listed in the dropdown lists.
 
Option B:
Chose "Opportunity Product" as workflow trigger object. Now you can set up all rules fine. The "oops" comes when you try to fire the new workflow by creating an opportunity that matches both rules mentioned above.
If you set the opportunity stage to the right value and after that add one matching product, all works perfect - but this just isn't the way we work. If you do it the other way around (select the product and then set the opportunity stage), the workflow won't be fired at all...
 
Any ideas on this one?
 
Cheers,
Harry
  • February 18, 2008
  • Like
  • 0
Hi,
I would like to know how to disable a button depending on activity being completed.

For Instance, I have an application that has two button
1. Print orginal (document)
2. Print duplicate.

Once the "Print Orginal" is clicked, it prints a report and inserts a value/flag  in the database and the "Print Orginal" should be disabled after this.
Users should be able to print only using the "Print Duplicate" button.

Thanks in advance
Nagen.
  • February 18, 2008
  • Like
  • 0
I'm trying to create a lead thru the API from an asp.net web form.  I'm not getting any errors when I run the page, but the lead is not created.
 
Not sure what I'm missing.
 
Here is the basic implementation of the code:
 
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text.RegularExpressions;
using CompassLearning.Data.Models;
using CompassLearning.Data;
using sforce = SforceService;
public partial class Controls_SupportForm : System.Web.UI.UserControl
{
    SforceService sfdc;
    protected void Page_Load(object sender, EventArgs e)
    {
       
    }
    private void login()
    {
        sfdc = new SforceService();
        LoginResult lr = sfdc.login("xxxxxxxxxxxxxxxxxxxxxx", "xxxxxxxxxxx");
        sfdc.Url = lr.serverUrl;
        sfdc.SessionHeaderValue = new SessionHeader();
        sfdc.SessionHeaderValue.sessionId = lr.sessionId;
        GetUserInfoResult userInfo = lr.userInfo;
    }
    private void createLead()
    {
        string phone = phoneAreaCode.Text + phonePrefix + phoneSuffix;
        Lead lead = new Lead();
        lead.FirstName = firstname.Text;
        lead.LastName = lastname.Text;
        lead.Street = address.Text;
        lead.City = city.Text;
        lead.State = state.SelectedValue;
        lead.PostalCode = zip.Text;
        lead.Phone = phone;
        lead.Email = email.Text;
        lead.Description = comment.Text;
        lead.LeadSource = "Web";
        sObject[] records = new sObject[] { lead };
        SaveResult[] sr = sfdc.create(records);
        for (int i = 0; i < sr.Length; i++)
        {
            if (sr[i].success)
            {
                Response.Write("Lead created successfully");
            }
            else
            {
                Error[] errors = sr[i].errors;
                for (int j = 0; j < errors.Length; j++)
                {
                    Response.Write(errors[j].message);
                }
            }
        }
    }
    protected void SubmitButton_Click(object sender, ImageClickEventArgs e)
    {
            login();
            createLead();
    }
   
}
 
Any help is appreciated.
Thanks.
    Hi All,

I have a requirement where i need  to report all the cases that are closed directly on first call. For this i am using the field, closed when created to capture the needed information. But unfortunately,this field is not getting populated with the value. On our analysis, we have found that this is because of overriding close button. we have overridden the close button to include business rules. is there any way how i can capture whether a case is closed by save& close button or by close button.

Pls reply me.

Thanks,
Udaya
Hi. I have created a custom object (Enquiry__c) and when this object is created or updated I want it to create or update a Contact record. I have added a custom lookup field to the Contact object that captures the Enquiry__c unique ID.

I have got the creating part of the trigger working but am struggling on the update. If I try to update an Enquiry__c record I get an error message "MISSING_ARGUMENT, Id not specified in an update call". I realise I must need to locate the ID for the relevant Contact record but have not worked out how to do this. Following is my code:

Code:
trigger enquiryInsertContact on Enquiry__c (after insert, before update) {
List<Contact> contacts = new Contact[0];
if (Trigger.isInsert) {
 for (Enquiry__c enq : Trigger.new) {
  contacts.add(new Contact (FirstName = enq.Enquiry_First_Name__c,
     LastName = enq.Enquiry_Surname__c,
     Salutation = enq.Salutation__c));
  }
 insert contacts;
 }
else if (Trigger.isUpdate) {
 for (Enquiry__c enq : Trigger.new) {
  contacts.add(new Contact (FirstName = enq.Enquiry_First_Name__c));
  }
 update contacts;
 }
}

 If anybody coudl point me in the right direction it would be greatly appreciated.

Cheers.

Hello all. Still muddling about and hoping someone can point me in the right direction.

Summary:
I have set up a "before insert" trigger for cases generated through Web-to-Case. (different recordtype) It's purpose is to lookup the Account/ContactID based on a number of fields in the web form. (SuppliedCompany, SuppliedEmail, etc...) On successful lookup, we want to assign the case to the appropriate owner of the associated Account. Otherwise, the case gets assigned to a special queue set up to handle these "orphaned" cases.

Everything works fine at the trigger/Apex class level. I confirmed by sending myself an email with the retrieved values and checking the data objects with sForce Explorer. However, no matter what I do, I cannot get the case OwnerId value to "stick". It keeps getting reset to the Default Case User's Id or whatever User/Queue is specified in the Assignment rules. I'm not sure why this is so because based on the update sequence here: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_order_of_execution.htm
assignment rules are processed after all triggers. i.e. it seems that the assignment rules on our sandbox over-write the looked-up OwnerId value.


Code:
public class WebCaseLookup {

public static void Execute (Case[] webcases) {
for(Case acase:webcases) {
String accountId = '';
String contactId = '';
String ownerId;
Account[] a;
Contact[] c;

// look up the contact based on the supplied email address c = [select id, AccountId from Contact where email = :acase.SuppliedEmail]; if (c.size() == 1) { contactId = c[0].id; accountId = c[0].AccountId;
// now get the account's owner
ownerId = [select OwnerId from Account where id = :accountId][0].OwnerId; }
// otherwise, try matching the account on the name
else { a = [select id, OwnerId from Account where name = :acase.SuppliedCompany]; if (a.size() == 1) { accountId = a[0].id; ownerId = a[0].OwnerId; } } if (contactId != '') { acase.ContactId = contactId; } if (accountId != '') { acase.AccountId = accountId; acase.OwnerId = ownerId; } // jsut a test custom field to check that the update is actually working
acase.Greg_Test__c = 'UPDATED'; //just an email routine for debugging purposes
//Notify('APex Code results', 'Apex code ran successfully and found ContactId ('+contactId+'), AccountId ('+accountId+') and OwnerId ('+ownerId+')'); } } }

 

  • February 16, 2008
  • Like
  • 0
I haven't figured out yet how you can build a custom object in one instance and then move it to another one thru Eclipse instead of packaging it or having to rebuild it in the new instance.  Any thoughts/ideas?  Thanks.
I am very new to salesforce and not at all technical.  I am having serious trouble trying to create 2 s-controls.  The first, I would like to have some of the fields show up on an Account Plan page...like annual revenue, number of employees, website, company description, etc....
 
The second, I would like to only pull contacts from the account linked to the account plan who meet certain criteria.  There would be a custom field for contact role (Decision Maker, Influencer, Executive Sponsor, Vendor/Procurement Management, etc...)  I only want those contacts' names, titles, emails to appear on the account plan if they have a defined role.
 
I've already spent about 2 days worth of effort trying to figure this out...I don't have premier support and nothing on the help/training menu has really helped me.  I've read the cookbook, played with sample codes and I'm still on square one.  I was hoping that someone out there could help me out.
 
Kathy