Update a field value when another field is edited

^bump^ :smiley:

I think the new actions on your junction model could work.
I’m using an action to update a date/time field when another field is changed on the same mode.

I have one action, which updates a field to the current date.  There’s a specific option for that.

In your case, I think you’ll need a snippet, since your wanting to update one model field with a value from another model field.

I’ve seen samples around that do that, but I’m still new to Skuid so I can help with specifics.  I’m just sure there’s lots of {} in it… :smiley:


I tend to agree with Seth.  This is not possible just using the action framework - in a table as you have. 

If you were able to get the process item in a model (by itself)  then you could add a new row to the junction object table and pass the default value for sequence to it.  I believe this would have to be a two step process.  1 being select the process - and filter the process model down to just that item,  and 2 populate the row in the junction object table. 

I also don’t think you are going to be able to have this function well in the “edit existing” scenario without some javascript. 

I was suspecting this. Basically think that I need to setup a listening function. Not even sure that’s what it is called.

On change, take the id of the reference and update a model condition with it in order to get access the desired data. Then I can update the second field.

It’s the listening part that I’m new to. Once I have the Id, then I’m good to go.

We got a similar thing working from this post - check out the first half of Ben’s answer. Admittedly I haven’t tried running this on a reference field, but what it basically does is:

When ‘this_field__c’ is updated, then get another value from the same row, and populate it into ‘second__field__c’

var params = arguments[0], <br>$ = skuid.$,<br>updates = params.updates,<br>defaultSequence; <br>//if the process reference field is updated by the user, <br>//then get the value of default sequence field for that row<br>//check that field is being pulled into the Process Model in your page <br>if ('Process__c' in updates) {<br>&nbsp; &nbsp;&nbsp;defaultSequence = params.row.defaultSequence__c;<br>&nbsp; &nbsp; }<br>&nbsp; &nbsp; if (defaultSequence) {<br>&nbsp; &nbsp; &nbsp; &nbsp; params.model.updateRow(params.row,'defaultSequence__c',defaultSequence); &nbsp;<br>&nbsp;&nbsp;&nbsp;}

See if you have any joy with that!


this also needs you to create an action on the model - when model is updated, then run the snippet.

Also, as it is a reference field, this line:


might need to be more like:


Greg. You are the man! That was exactly what I was looking for. This is the code I ended up with.

var params = arguments[0], $ = skuid.$, updates = params.updates; // if the process reference field is updated by the user, // then get the value of default sequence field for that row // check that field is being pulled into the Process Model in your page if ('RECON__Process__c' in updates) { var processModel = skuid.$M('CurrentLibProcess'), proModCond = processModel.getConditionByName('ProId'), defaultSequence; // set and activate condition processModel.setCondition(proModCond,params.row.RECON__Process__c); processModel.activateCondition(proModCond); // query model and wait til done before getting row and updating row $.when(processModel.updateData()) .done(function(){ processRow = processModel.getFirstRow(); defaultSequence = processRow.RECON__Sequence__c; params.model.updateRow(params.row,'RECON__Sequence__c',defaultSequence); }) .fail(function(){ }); }<br>

Nice. looks like you took it to another level there setting the conditions and querying the junction object.

Yup. As far as I know I had to do that. Still new to Skuid (3 months) and Javascript (1 month)

Well done… quickly passing all of up…