How to send the newly created salesforce id to a Custom APEX action as a parameter

  • 1
  • Question
  • Updated 2 years ago
  • In Progress
I want to update the newly created salesforce id to a field in different model. Please find my below

var prevAppModel = skuid.model.getModel('PrevApplication');var prevAppRow = prevAppModel.getFirstRow();


....
..
....
....
result = sforce.apex.execute('CreateNewLoanApplication','createApplication', param);        
        var relMsg = result.toString().split('##');
       alert("### "+relMsg[0]+relMsg[1]);
       if (relMsg[0] === 'FAILED') {
           alert(relMsg[1]);
          
       } else {
           alert("Application Created Successfully.");
           alert(result);
           prevAppRow.Refinance_RB_Id__c = result;
           alert(prevAppRow.Refinance_RB_Id__c);
           alert(prevAppRow.Id);
           prevAppModel.updateData();
}


I am able to alert the result with the newly created id but the model is never getting updated
Photo of Shiva Chervirala

Shiva Chervirala

  • 200 Points 100 badge 2x thumb

Posted 2 years ago

  • 1
Photo of Pete O'Connell

Pete O'Connell

  • 214 Points 100 badge 2x thumb
Use the updateRow function and it should work.
Photo of Shiva Chervirala

Shiva Chervirala

  • 200 Points 100 badge 2x thumb
Hi Pete,

Thanks for your immediate response.Tried but did not  work can you please give me the exact syntax if possible.
(Edited)
Photo of Pete O'Connell

Pete O'Connell

  • 214 Points 100 badge 2x thumb
var prevAppModel = skuid.model.getModel('PrevApplication'),
    prevAppRow = prevAppModel.getFirstRow();
....
....
....
....
result = sforce.apex.execute('CreateNewLoanApplication','createApplication', param);          
var relMsg = result.toString().split('##');
alert("### "+relMsg[0]+relMsg[1]);
if (relMsg[0] === 'FAILED') {
    alert(relMsg[1]);
} else {
    alert("Application Created Successfully.");
    alert(result);
    // updated syntax below
    var changes = {
        Refinance_RB_Id__c: result
    };
    prevAppModel.updateRow(prevAppRow, changes);
}
I updated the syntax at the end. Let me know if you have any questions :)
Photo of Shiva Chervirala

Shiva Chervirala

  • 200 Points 100 badge 2x thumb
Thanks Pete. I dont know for some reason the vale is never getting updated in the column . I have even run an save model after the snippet to make sure the data is saved.

I have to send the newly created id to the custom apex action. I tried too many way and thought that I would update to a field and send the field value but No luck. Any insights would help me a lot. Thanks in Advance
Photo of Pete O'Connell

Pete O'Connell

  • 214 Points 100 badge 2x thumb
It looks like you are trying to create a hierarchy of applications. If that's true, take care of this inside the apex class that you call out to and re-query the models. It seems like this should be a behavior of that method. If this is not true, please let me know what the goal is.
Photo of Shiva Chervirala

Shiva Chervirala

  • 200 Points 100 badge 2x thumb
Okay Let me put it in another way. Im cloning an application manually by populating few fields. As I have to clone the related  child records.I cannot modify in CreateNewLoanApplication  as it is being called from various locations. I thought of calling an APEX action to which I have to pass both the previous application Id and newly created application Id.

I have two models in my SKUID page one for previous application ,which is conditioned with id = prevapp id and new application model to create a new application.