You need to sign in to do that
Don't have an account?
iatschuck
create new record cominbed with different sobject fields
I would like to use javascript function to add a new custom sobject record. But I have a problem to create a new record.
I created custom subject, which has a lookup relationship field form other custom sobject. I have following code.
var c = new sforce.SObject("sobject1");
c.Name=’AAA’;
c.sobject2.Name=’BBBB’; ß this is not allowed
sforce.connection.create([c]);
Can anyone please let me know how I can assign value to sobject2 fields?
Thanks
I created custom subject, which has a lookup relationship field form other custom sobject. I have following code.
var c = new sforce.SObject("sobject1");
c.Name=’AAA’;
c.sobject2.Name=’BBBB’; ß this is not allowed
sforce.connection.create([c]);
Can anyone please let me know how I can assign value to sobject2 fields?
Thanks
You have 2 sobjects: sobject1 and sobject2
In order to create a new sobject1 record with the lookup to sobject2, you need to set the Id of sobject2.
Assuming that you retrieve the sobject2 id somewhere else in the code, the javascript would then be:
var c = new sforce.SObject("sobject1"); c.Name=’AAA’; c.sobject2lookup__c = sobject2.id; sforce.connection.create([c]);
where sobject2lookup__c is your lookup relationship field