Help!! Not able to render a field based on the option selected in the picklist while in edit mode

  • 1
  • Problem
  • Updated 3 months ago
  • Solved
I'm using the below custom snippet for a field. 

I'm not able to render the field when I select a value from the picklist value while i'm in edit mode. What I want is when the user selects Full or Partial from the picklist, I want to auto populate another field. I know how to update a value to another field but my problem is I'm not able to trigger this action when I select Full or Partial.

var $ = skuid.$;
var field = arguments[0],
    value = arguments[1],
    model = field.model,
    row = field.row;
var totalsize;

switch(field.mode)
        {
            case 'read':
                skuid.ui.getFieldRenderer(field.metadata.displaytype).read( field, value );
                switch (value)
                {
                    case 'Partial':
                   
                    break;

                    case 'Full':
                       
                        var totalsize=model.getFieldValue(row,'Program__r.Survey_Size__c');
                        
                        model.updateRow(row,'Total_Project_Size__c',totalsize);

                    break;
                        
                }
            break;


            case 'edit':
                
                skuid.ui.fieldRenderers[field.metadata.displaytype][field.mode](field,value);
               
switch (value)
                {
                    case 'Partial':
                        
                    break;
                    case 'Full':
                       
                        totalsize=model.getFieldValue(row,'Program__r.Survey_Size__c');
                        model.updateRow(row,'Total_Project_Size__c',totalsize);
                    break;
                        
                }
            break;
            
            case 'readonly':
        }










Photo of Toms Vineeth John

Toms Vineeth John

  • 428 Points 250 badge 2x thumb

Posted 4 months ago

  • 1
Photo of Toms Vineeth John

Toms Vineeth John

  • 428 Points 250 badge 2x thumb
Any help or guidance appreciated..  
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
I believe you can just use a declarative model action with a 'field on a row changes' trigger to start an action sequence with a Branch and a Update field on Row action to get what you're after.
Photo of Toms Vineeth John

Toms Vineeth John

  • 428 Points 250 badge 2x thumb
Sorry for my ignorance. Where can I find 'Field on a row changes' trigger
Photo of Peter Kong

Peter Kong, Employee

  • 440 Points 250 badge 2x thumb
EDIT: For your use case, you might need to use a Branch action as well.

Hi there!

Here are some screenshots of how to get there :)

1. Select a Model, select "Actions".


2. Add a Model Action by clicking the "+" shown above. Note the Model Action Properties pane to the right.


3. Select the "Row in Model Updated" Action. This will enable another option "When which field(s) are updated?".


4. Click the "When which field(s) are updated?" property, and here you can select any fields you have enabled for the Model. So in this case, I would just select the "Name" field.


5. Click the "Actions" tab. This will allow me to define my series of actions that will trigger whenever the "Name" field is ever modified!


For more info on Actions like these, here's a link to our docs that has most of our Model Actions:

https://docs.skuid.com/latest/en/skuid/models/model-actions.html
(Edited)
Photo of Toms Vineeth John

Toms Vineeth John

  • 428 Points 250 badge 2x thumb
Thank you. It worked like charm. I didn't know about Branch. a great logic.