+ Start a Discussion
A Dev in NZA Dev in NZ 

Updating a field with a related Objects field Value

Hi,
I am trying to get related Object info using S-Control or the like.
Can you please help.
 
1.   Reason for me doing this is I have reached the limit of 5 cross objects within formulas. SFDC support suggest I use S-Control.
2.   For example I wish to retrieve fields within an "Account" that are related by a "Account Name" lookup to a "Contract", both standard objects. And then place those retrieved fields into my "Contract".
3.   I am current trying to do this with an S-Control that executes when I hit the "EDIT" button on any "Contract Detail page".
4.   I am also trying to bring through multiple "Contact" fields, "Opportunity" fields, and "User" fields. Hence reaching my limit.
5.   I would love to be update these dependant Contract Fields on selecting the lookup parent field, but I am happy with executing on "EDIT"
 
Q1: This is the type of code I am trying but it fails within S-Control
Q2: Also the related field may contain a picklist, is that a problem.
  ...
result = sforce.connection.retrieve("Name,Phone", "Account", [result[0].id]);
...
  result = sforce.connection.update([contract]);

  if (result[0].getBoolean("success")) {
    log("account with id " + result[0].id + " updated");
  } else {
    log("failed to update account " + result[0]);
  }
...