• milliskenny
  • NEWBIE
  • 0 Points
  • Member since 2006

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
I am trying to implement an inline s-control with SFDC formatting, however I can't find any documentation that states what the "X" should be in CustomXTab when trying to use a custom tab's formatting in the class attribute of an object. Thanks

Message Edited by milliskenny on 10-22-2007 07:28 AM

Hopefully this is an easy one.  In the code below, I create a custom object (Dept) that has a one to many relationship with the contact (one Dept to many contacts).  The s-control starts from the contact and creates the new Dept with the account_id and the address information from the contact.  I use the create function on the Dynabean to create the Dept, and then retrieve the Id of the new object so I can open the record in the modal window.
 
The issue arises when I try to update the Contact record with the id of the new Dept.  I get a javascript error referencing line 3653, with the error message of "exception thrown and not caught".
 
I am pretty new to all this stuff, so I looked at the js library file for AJAX 3.3 beta and the function around line 3653 reads:
 
Sforce.Dynabean.prototype.set = function(propName, value) {
 var fldDef = this.definition.fieldMap.getItem(propName);
 var cr = this.definition.childRelationships.getItem(propName.toLowerCase());
 var rn = this.definition.parentRelationships.getItem(propName.toLowerCase());
 if (fldDef == null && cr == null && rn == null) {
  throw "The property " + propName + " is not a valid field.";
 } else {     <----- This is line 3653
  //Validate type if possible
  //TODO validate other types
  if (fldDef != null) {
   if (fldDef.type == "date" || fldDef.type == "datetime") {
    if (Sforce.Util.dltypeof(value) != "date" && Sforce.Util.dltypeof(value) != "datetime" && value != null) {
     throw "Invalid type: You passed a " + Sforce.Util.dltypeof(value) + " but the field requires a " + fldDef.type + ".";
    }
   }
  }
 
It appears that it cannot find a reference to the field I want to write back to.  The field is of type "lookup" and should reference a Dept related object.
 
Here is the section of the code where I do the update.  Thanks in advance for any help!
 
//This is where I create the new Dept
var newDeptList = new Array();

var newDept = new Sforce.Dynabean("Department__c");
newDept.set("Id","");
newDept.set("Name", name + " - " + deptPrompt );
newDept.set("Account__c", "{!Account_Id}" );
newDept.set("Legal_Entity__c", legal_entity);
newDept.set("Address__c",mailing_street);
newDept.set("City__c",mailing_city);
newDept.set("StateProvince__c",mailing_state);
newDept.set("Country__c",mailing_country);
newDept.set("Postal_Code__c",mailing_postalcode);

newDeptList[0] = newDept;

// Create new Department
results = sforceClient.Create(newDeptList);

//If the first value in the result array is null then it's a fault.

if( results[0] != null &&
results[0].success == true )
 
//Now I go to get the Id of the new dept record I created
{
// Fetch department id
newDeptId = results[0].id;


//Update the existing contact with the new Dept ID
var contactUpdateList = new Array();

var contactUpdate = new Sforce.Dynabean("contact");
contactUpdate.set("Id","{!Contact_Id}");
 
//The next line is where it fails
contactUpdate.set("NewDepartment__c",newDeptId);

contactUpdateList[0] = contactUpdate;

//Update the Contact
var resultsCon = sforceClient.update(contactUpdateList);

contactUpdateList.save();
 

Message Edited by milliskenny on 10-03-2006 01:51 AM

I am trying to implement an inline s-control with SFDC formatting, however I can't find any documentation that states what the "X" should be in CustomXTab when trying to use a custom tab's formatting in the class attribute of an object. Thanks

Message Edited by milliskenny on 10-22-2007 07:28 AM

Is it possible at this point to use the AJAX toolkit in the sandbox?  I've tried simply logging in as follows and it doesn't work... any ideas?

Code:
<script src="https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js" type="text/javascript"></script>

<script type="text/javascript">

   sforceClient.setLoginUrl('https://test.salesforce.com');

   var loginresult = sforceClient.Login("sandbox_username","sandbox_password");

   sforceClient.setUrl(loginresult.serverURL);

   alert(loginresult.sessionID);

</script>
 
 
 
I hope this isn't a stupid question (I new to Salesforce.com): Is it possible to have custom links displayed when editing a contact?
Here's why: I want to implement a multi-select field where the options are generated from a query againast a custom object.
The standard multi-select field takes it's options list from the field definition, so to add or remove options I need to edit the field.
What I want is more data driven than that, so I thought I'd create an  S-Control using AJAX toolkit to perform a query against the DB, and  present a list of checkboxes for the user. The S-Control would update a field (text or text area) using values checked in the form when the user presses a ok button  (all pretty standard stuff I guess).

However, I need a custom link to call the S-Control, and the "custom-links" section of the form is not presented when I edit the contact record.
Am I missing something ???

GOC
  • September 23, 2006
  • Like
  • 0