You need to sign in to do that
Don't have an account?

how to access multiple values from a custom setting in javascript on click button?
{!REQUIRESCRIPT("/xdomain/xdomain.js")} {!REQUIRESCRIPT("/soap/ajax/39.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/39.0/apex.js")} {!REQUIRESCRIPT("/support/console/39.0/integration.js")} var Program='{!Program_Member_MVN__c.Program_Name__c}'; var Pname=sforce.connection.query("Select Program__c from Program_Names__c"); var rec16 = Pname.getArray('records'); var status='{!Program_Member_MVN__c.Status_MVN__c}'; var PmId='{!JSENCODE(Program_Member_MVN__c.Id)}'; var PName='{!Program_Member_MVN__c.Program_Name__c}'; var url; if (sforce.console.isInConsole()) { if(Program == rec16){ alert("You are on the wrong Program") } else if(status == 'On Therapy') { url = "/apex/Milestone_skip?id="+PmId; window.open(url,'_blank','toolbar=0,location=0,menubar=0,width=800,scrollbars'); } else { alert("Patient must be ‘On-Therapy’ before skipping to a milestone"); } }
This is my java script on click button code.In this i am querying custom setting here:var Pname=sforce.connection.query("Select Program__c from Program_Names__c");
And i want to compare to field to show a alert.So i have to multiple values in custom setting.So how can i access all the values given in the custom setting in the java script code?
All Answers
The result you get in var rec16 i.e(var rec16 = Pname.getArray('records')) is in json format you need to parse it and can easily get the field value one by one for e.g.
I hope this will help you to solve your problem
Thanks,
Sukanya Banekar
Hi sukanya banekar
I have to compare var program to what ever is there in custom settings.So i have changed my code as above.Is it the correct approach?And i am getting unexpected or invalid token error.How to solve that error?
I am getting invalid or unexpected token error.I think syntax is correct and all flower brackets are closed still i am getting the error.What may be the issue?Thank you for the reply.
alert('record----'+record)
alert('json----'+json)
alert('obj.Stage_Name__c----'+obj.Stage_Name__c)
alert('Program----'+Program);
Try to debug the code. and let me know the result.
Thanks,
Sukanya Banekar
Thank you for all your replies.It is now working:)