Update date field from another model

edited June 25, 2020 in Questions
I have 2 models:  Program and Timeline, both have a field named Mail_Date__c.   When the Program model Mail_Date__c is updated, need Timeline model Mail_Date__c to update to that same date.   Action Framework only allows specific dates, so am using Snippet, but am unable to find the correct syntax.   Here is what I have so far that is not working:

var params = arguments[0], $ = skuid.$;
var model = skuid.$M('Timeline');
var row = model.getFirstRow();
model.updateRow(row,{


Mail_Date__c: Program__r.Mail_Date__c
});

I assume the last line needs help.  Thanks!

Comments

  • Pat VachonPat Vachon 💎💎💎
    edited June 25, 2020
    Is the Timeline model is related to the Program model with the Program__c field?
    Do both models have the Mail_Date__c fields?

    Assuming yes to both above, then the issue is that Program__r.Mail_Date__c in Timeline model isn't yet updated with the Mail_Date__c on Program model. It would still have the value it had when the page loaded. That's even if you saved the Program model. You could of course requery the Timeline model, but that's a poor UX.

    I'd just add the Program model and row to the snippet in order to use it in the updateRow function. ie. programModelRow.Mail_Date__c in place of Program__r.Mail_Date__c

    Cheers
  • AnnAnn
    edited February 6, 2019
    Yes, the Timeline model is related to Program model with Program__c, and both models have the Mail_Date__c fields

    Tried programModelRow.Mail_Date__c in place of Program__r.Mail_Date__c and still not working.

    Running a test, I am able to update the Timeline field to 'null' without problem (below)
    var params = arguments[0], $ = skuid.$;
    var model = skuid.$M('Timeline');
    var row = model.getFirstRow();
    model.updateRow(row,{


    Mail_Date__c: null 
    });


  • edited June 25, 2020
    You may be able to accomplish this with a flow, process, or workflow if you can't get the snippet to work.
  • Pat VachonPat Vachon 💎💎💎
    edited July 17, 2017
    Yup. Process will do it the easiest in SF.

  • edited July 17, 2017
    Thanks for all of the suggestions!  Went with Salesforce process builder and works great!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!