function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Stavros McGillicuddyStavros McGillicuddy 

Unexpected identifier error when copying one field to another

On my Opportunity object: I have created six custom fields
AVSFQB__Generate_Object__c  (picklist)
AVSFQB__Quickbooks_Id__c  (text 50 - External ID)
AVSFQB__QuickBooks_ItemType__c   (picklist)
Sample_Generate__c  (text 100)
Sample_Quickbooks_ID__c   (text 50)
Sample_QuickBooks_ItemType__c   (text 100)
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

I am trying to get this code to work with one set of fields before I add the others

This code produces 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();

 
@CA@CA
Try the below code

​{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 
var record = new sforce.SObject(Opportunity); 
record.Id = ("Opportunity.Id"); 
record.Sample_Generate__c = {!Opportunity.AVSFQB__Generate_Object__c}; 
var result = sforce.connection.update([record]); // check the result here window.location.reload();



Let me know if it doesn't work
Stavros McGillicuddyStavros McGillicuddy
Helllo CA.
Thank you for your response.
Unfortunately this didn't work. I get the same error.. "A problem with the OnClick JavaScript for this button or link was encountered: Unexpected identifier."
 
Stavros McGillicuddyStavros McGillicuddy
(polite bump) 
Nitish AgrawalNitish Agrawal
I am facing similar issue. Please let em know if you got a soultion for this.

Thanks