You need to sign in to do that
Don't have an account?
Sarah Burton
JavaScript button not working
Hi There
I am trying to create a button which will sit in the Opportunity related list which allows you to update the field 'POP Request' on all the product lines you use in the Multi Picklist. I am getting the following message:
Error Message: <span class="errorStyle">Error: The Name field is required.</span>
This is the first time I have tried this so any help is much appreciated!
Thanks, Sarah
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var p = new sforce.SObject('OpportunityLineItem');
p.id = "{OpportunityLineItem.Id}";
p.POP_Request__c = TRUE;
result = sforce.connection.update([p]);
location.reload(true);
I am trying to create a button which will sit in the Opportunity related list which allows you to update the field 'POP Request' on all the product lines you use in the Multi Picklist. I am getting the following message:
Error Message: <span class="errorStyle">Error: The Name field is required.</span>
This is the first time I have tried this so any help is much appreciated!
Thanks, Sarah
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var p = new sforce.SObject('OpportunityLineItem');
p.id = "{OpportunityLineItem.Id}";
p.POP_Request__c = TRUE;
result = sforce.connection.update([p]);
location.reload(true);
However your ajax version is WAY outdated. Use version 43, that's the most recent.
{!REQUIRESCRIPT("/soap/ajax/43.0/connection.js")}
Also, javascript in Salesforce seems to be getting slowly phased out. You may want to look into other options for what you are trying to accomplish.
Good luck!
var p = new sforce.SObject("OpportunityLineItem");
p.id = '{!OpportunityLineItem.Id}';
Also needed that ! before the OppLineItem
I tried the following an didnt work unfortuantely. This is all totally new to me so I am winging it if I'm honest!
No problem about Java being phased out... this is a quick fix until the team get on lightning :)
{!REQUIRESCRIPT("/soap/ajax/43.0/connection.js")}
var p = new sforce.SObject("OpportunityLineItem");
p.id = '{!OpportunityLineItem.Id}';
p.Pop_Request_Picklist__c = "Yes";
result = sforce.connection.update([p]);
location.reload(true);
When I clicked the button it said:
Failed to Update! Error: {errors:{message:'Id not specified in an update call', statusCode:'MISSING_ARGUMENT', }, id:null, success:'false', }
Have I gone about this in the wrong way?
Just leave it as "sforce.connection.update([p]);" OR [oli] which ever variable youre using for OppLineItem
I have a similar Javascript button I no longer use and it just had "sforce.connection.update([L]);" to update my Leads