Could any one help me to change salesforce Javascript execute button to Skuid custom button ?

  • 1
  • Question
  • Updated 3 years ago
  • Answered
Hi ,

I am new to skuid and I have an execute javascript button on Courses__c custom object it's related to Lead.I have tried to write javascript snipet code  and I made some changes to my code but it doesn't work for me. So could you please help me to create custom button in skuid with above code.

And my button code is

{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}

var updateRecord = new Array();
var myquery = "SELECT Id,Centre__c FROM Lead WHERE Id = '{!Lead.Id}' limit 1";

result = sforce.connection.query(myquery);
records = result.getArray("records");

if(records[0].Centre__c==null)
{
alert('Please select Centre on Enquiries ')
}
else{
window.open("/apex/AddNewCourse?leadId={!Lead.Id}","_self");
}


Thanks.
Photo of Deleep Manda

Deleep Manda

  • 246 Points 100 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
I'm assuming that your button is on a page title bound to a model that grabs a single lead.  
No guarantees but I think your code would look like this

var params = arguments[0],
$ = skuid.$,
field = arguments[0],
row = field.row,
centre = row.Centre__c;
lead = row.Leia
if(centre==null) 

alert('Please select Centre on Enquiries ') 

else{ 
var urlString = "/apex/AddNewCourse?leadId=" + lead
window.open(urlString,"_self"); 
}
Photo of Deleep Manda

Deleep Manda

  • 246 Points 100 badge 2x thumb
Thanks for the help Rob :)
I have changed the code like following and it's working fine

var params = arguments[0], $ = skuid.$;
var leadModel=skuid.model.getModel('LeadDetailQueue');
alert("leadModel "+leadModel);
    var leadRow=leadModel.getFirstRow();
    var centre=leadRow.Centre__c;
    var id=leadRow.Id;
if(centre===null) 

alert('Please select Centre on Enquiries ') ;

else{ 
var urlString = "/apex/c__AddNewCourse?leadId=" + id;
window.open(urlString,"_self"); 
}    


Deleep
(Edited)
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Thanks for posting Deleep.  Hope it works successfully for you.