0

I have a dropdown which needs to populate data dynamically from the custom setting records in salesforce using the javascript remoting. Can anyone tell me how can I achieve this? I am very new to this so it will be a great help. thanks I tried the following here is my javascript

var readEquiFaxConditionsModule = (function(){
return {
getEquiFaxConditionData : function(){
CreditScoreManagerController.getApprovalTypeList(function(result,event){
if(event.status){
alert("Success"+result);
}else if(event.type === 'exception'){
// error
}
else {
//error
}
});
}
}
})();

and in the console.log I am getting my data with success =. Now the problem is how do I assign that to my dropdown?

  • 1
    you can try out something at your own and if you face any issues, post that – Santanu Boral Oct 11 '16 at 15:21
0

You can do something like this in your javascript

if(event.status){
var newDiv=document.createElement('div');
   var html = '<select>',  i;
   for(i = 0; i < result.length; i++) {
       html += "<option value='"+result[i]+"'>"+result[i]+"</option>";
   }
   html += '</select>';
   newDiv.innerHTML= html;
   document.getElementById('TheParentComponentId').appendChild(newDiv);
}

if your result is type of Sobject or wrapper list you can access it like result[i].Name //this is just a example

  • @user5129806 glad to help you. Welcome – Tushar Sharma Oct 11 '16 at 17:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.