On my Opportunity object:
I have created six custom fields
- AVSFQB__Generate_Object__c
- AVSFQB__Quickbooks_Id__c
- AVSFQB__QuickBooks_ItemType__c
- Sample_Generate__c
- Sample_Quickbooks_ID__c
- Sample_QuickBooks_ItemType__c
I have also created a custom button Process_Sample_Sent
I would like to click the button and move the field contents:
- AVSFQB__Generate_Object__c to Sample_Generate__c
- AVSFQB__Quickbooks_Id__c to Sample_Quickbooks_ID__c
- AVSFQB__QuickBooks_ItemType__c to Sample_QuickBooks_ItemType__c
On the custom button, I have selected:
- Display type - Detail Page Button
- Behavior - Execute JavaScript
Content Source - OnClick JavaScript
{!Opportunity.Sample_Generate__c} = {!Opportunity.AVSFQB__Generate_Object__c} {!Opportunity.Sample_Quickbooks_ID__c} = {!Opportunity.AVSFQB__Quickbooks_Id__c} {!Opportunity.Sample_QuickBooks_ItemType__c} = !Opportunity.AVSFQB__QuickBooks_ItemType__c}
This throws an "Unexpected token = " error
Here is my modified code that is throwing the same error.
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var record = new sforce.SObject("Opportunity__c");
record.Id = ("Opportunity__c.Id");
record.{!Opportunity.Sample_Generate__c} = {!Opportunity.AVSFQB__Generate_Object__c};
var result = sforce.connection.update([record]);
// check the result here
window.location.reload();
Thank you Ardian, Here is the code edited with your suggestion. It is throwing an "Unexpected Identifier" error
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var record = new sforce.SObject("Opportunity__c");
record.Id = ("Opportunity__c.Id");
record.Sample_Generate__c = {!Opportunity.AVSFQB__Generate_Object__c};
var result = sforce.connection.update([record]);
// check the result here
window.location.reload();
ARGH.. I didn't mention, AVSFQB__Generate_Object__c is a PICKLIST and Sample_Generate__c is a TEXT field. I am trying to capture the PICKLIST value into the TEST field