delayed condition

  • 1
  • Question
  • Updated 2 years ago
  • In Progress
Hi,

Wondering if anyone has an idea, on how I could accomplish it

We have a whole lengthy application process, and often agents will forget to enter information in some key fields.

At the end of the process, I created a page with 'Missing  information'. Basically input all the fields that I want to remind them about, and on each I have a condition to show the fields if =Null

That works fine. The problem is the moment they start typing in one of those fields, because of condition (no longer null) it disappears before we have the chance to completely finishing typing.


Those fields depending on situation , may or may not need to have info, so making them mandatory is not a solution for me. 
As well for them to go back in the beginning of the process, is not very efficient.

Would there be some way I can delay that condition until I finished typing in field?

Or some other way i accomplish my goal?

Thank you
Photo of Dave

Dave

  • 5,538 Points 5k badge 2x thumb

Posted 2 years ago

  • 1
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
What if you have them complete the form, click a button that saves the record and marks a field as "preliminary", then opens up a popup window that has a separate model for each of your required fields. Then each model can have two conditions:
1) record ID= the record Id you are working on
2) requiredField1 is blank.
Then you add a separate field editor for each of the models
Then you make those fields required
Then you have a save button at the bottom that changes the preliminary field to final and saves the record.
Photo of Dave

Dave

  • 5,538 Points 5k badge 2x thumb
Thank you for suggestion it could be a potential solution , but the problem is there's  about 100 fields lol.
So would need to create 100 models and logic for each 1 by 1...
Which I rather not have to do by choice :D
Photo of Mark DeSimone

Mark DeSimone, Official Rep

  • 11,050 Points 10k badge 2x thumb
Hi Dave. 

You may be able to use the "Render if..." setting to render the field "if ANY conditions are met." Then, you could retain your if =null condition, and add another one that tracks whether a field should be displayed even if it's not null (basically, if it's being filled out). For example, you can set a condition up with the Source Type: Model Property (or Row Property). Then, the Model (or Row) Property could be set to "Has unsaved changes." If this lengthy application process is set up to save the changes as the user goes along, then your Missing Information page could watch for any new unsaved changes, which would show up as the user begins typing. 

If your needs are more complicated than the ANY option can meet, you may be able to make use of Grouping Logic. It's briefly explained here at the bottom of the page, but in a nutshell, you can group conditions together in complex ways like ((1 and 2) OR (3 and 4) OR 5), where each of those numbers represents one of the conditions you've set (notice the editor numbers conditions as you add them). That example of custom render logic would allow its field to render if both conditions 1 and 2 were true, OR if conditions 3 and 4 were both true, OR if condition 5 was true - three scenarios, each of which may have more than one condition to check.

Also, if you end up with a solution that needs to be added to a large number of fields, you might consider editing the XML directly, and carefully copying and pasting the render condition to each field that should have it. Be careful with this approach so that the XML stays valid, and that the conditions will actually make contextual sense when they're transplanted (save often!). 

Hope this helps!
Mark
Photo of Dave

Dave

  • 5,538 Points 5k badge 2x thumb
Hi Mark,

Thank you for response and it almost works!

But 1 unforeseen issue, I added a 2nd condition to each field to show if null OR Has unsaved Changes

and it works, the problem happens that as soon as any 1 field has unsaved changes, all the fields appears 

My Goal was to have shown here only the fields missing info and allow agents to fill information directly in that page

Let me know

Thx
Photo of Mark DeSimone

Mark DeSimone, Official Rep

  • 11,050 Points 10k badge 2x thumb
It may be that if a record's row has any unsaved changes, it'll trigger the 2nd condition for all the fields on that row, not just the changed field. So in your use-case, this option may not get quite as granular as you'd need. 

Perhaps you could consider loading a new model (or models) for this missing information page to allow users to review all their entries. If the process is lengthy as you describe, this might be useful for them anyway. If you set the field editor/editors to default to Edit mode, users can see which fields have data already, and which don't, and easily fill things out. You could ask the user to review the data and be sure to fill in all areas.

We like to encourage declarative solutions whenever possible, but there is also the ability to set a condition that will activate if a Javascript snippet returns true, and that may allow you to evaluate the field just how you want it, and achieve that extra granularity. 

-Mark
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
How about loading all of the field in one model and adding checkbox fields (maybe UI only) that correspond to each field and only render if the field is blank? Make the checkboxes required so that if they are rendered, the user has to check them. Title the checkboxes "Reviewed". That way you can get required confirmation that the user intentiallonally left the field blank without making the field itself require an answer.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Does anyone know if snippets for 'result of a snippet' rendering conditions are passed arguments yet?

if they get arguments, you could try a result of a snippet, wher ethe snippet would check if the field in context is in the changes object of the model in context. I'm not totally certain that would work, depending on how/when skuid evaluates the rendering condition snippet.

Perhaps simply a custom field renderer like this?

var field = arguments[0], value = arguments[1], $ = skuid.$;
var row = field.row, model= field.model;
var renderField = (value) ? false: true; // If the field doesn't have a value, we want to render it;
//Check if the field has unsaved changes
if (!renderField && model.hasChanged) {
    var changesRow = model.changes && model.changes[row.Id];
    If (changesRow && changesRow.hasOwnProperty(field.id)) {
        renderField = true; //If the field is in the model and row's changes object, we want to render it
    }
}
//only call the renderer if renderField is true
if (renderField) skuid.ui.fieldRenderers[field.metadata.displaytype][field.mode](field,value);
(Edited)