I am trying to call apex web service using following code in salesforce and it working fine.
and I created javaScript snippet code in skuid with some changes but I am getting an issue with this.Could please anyone help me to resolve this issue.
Salesforce :
sforce.connection.sessionId = “{!$Api.Session_ID}”;
orderedChkBox = “{!Opportunity.Ordered__c}”;
oppId = “{!Opportunity.Id}”;
idArray = {!GETRECORDIDS($ObjectType.OpportunityLineItem)};
if(idArray.length == 0)
{
alert(‘You have not selected any line items to convert.Please select the line items.’);
}
else if (idArray.length > 0)
{
var executionId = “” +sforce.apex.execute(“createAgentCommission”,“convertLineItems”,{lineItemIds :idArray,oppId : oppId});
if(executionId == ‘The Line items which you have selected have already been converted.Please select a different line item.’ && executionId != null){
alert(executionId);
}
else{
alert(executionId);
location.reload(true);
}
}
SKUID JS Snippet:
var params = arguments[0], list=params.list,
selectedItems = list.getSelectedItems(),
$ = skuid.$;
var records = skuid.$.map(arguments[0].list.getSelectedItems(),function(item){
return item.row.Id;
});
alert(‘test’);
var opp = skuid.model.getModel(‘Application’);
var oppRow = opp.getFirstRow();
var orderedChkBox =oppRow.Ordered__c;
var oppId =oppRow.Id;
alert(oppId);
sforce.connection.sessionId = “{{$Api.Session_ID}}”;
if(records.length === 0)
{
alert(‘You have not selected any line items to convert.Please select the line items.’);
}
else if (records.length > 0)
{
console.log(‘sforce-’+sforce.apex);
var executionId = sforce.apex.execute(“createAgentCommission”,“convertLineItems”,{lineItemIds :records[0],oppId:oppId});
if(executionId == ‘The Line items which you have selected have already been converted.Please select a different line item.’ && executionId !== null){
alert(executionId);
}
else{
alert(executionId);
window.location.reload();
}
}
Question
Problem with JavaScript Execute button

This topic has been closed for comments
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.