Conditional Popup/Warning after save

HI,

I’m trying to accomplish the following, and not sure it’s possible with Skuid.

After saving a record I would like for a way to  show a popup/warning if certain conditions are met or not met

Example of my main use:

I have a formula field to validate certain numbers entered. If that formula result does not match a value entered in X field, I want to be able to show that warning/popup

The reason i cannot use SF validations, is that in certain cases, it will not match, but I still want to be able to show the Warning, so they can double check the #s entered.

The problem i’m experiencing is that the condition has to be after Save is executed, as formula field would only calculate after save.

This is the reason i cannot use a custom “save button” with multiple actions and conditional rendering.

Basically the order of actions would be
-Save
-Check 1 or more conditions
-If condition(s) met, to show the popup/warning

if anyone could help me out, i will appreciate it

If need more details do not hesitate to ask

Thank you

Dave,

This will take a little javascript, but you can do it!

create a javascript snippet in your action framework that looks something like this:

// get your model and row<br>var model = skuid.$M('MyModel'),<br>row = model.getFirstRow();<br>//set your shortcuts and initial variables.<br>returnVal = true;<br>$ = skuid.$;<br>//get the values of the formula fields you're interested in:<br>var value1 = model.getFieldValue(row, 'MyFormulaField1__c'),<br>value2 = model.getFieldValue(row, 'MyFormulaField2__c');<br>//Create your conditional statements<br>if (value1 == 'Some value which should case the popup' || value2 == 'Some other value which should cause the popup') {<br>returnVal = false;<br>}<br>return returnVal;


Your action framework should include this snippet after save, and include the warning popup as an ‘on-error’ action.

As an alternative to all of that, you could just build your formula fields as ui-only formula fields in skuid, and then you could do the validation immediately, before save.

Matt,

I tried the UI Only approach quickly but did not seem to work for me but will try again .

But ty very much for javaScript, I’m sure that will be extremely useful if i cannot do it with UI fields (specially that i have no JS knowledge ) :slight_smile:

Thx!


Matt,

I just tried the JS you provided and it was a breeze, thx to Script provided. And ty for comments added, it will allow me to modify this script for different uses :slight_smile:

Now do you know by any chance, how can i get my custom Save button to behave same as the standard Skuid Save Button (greyed out until some field has been changed)?

I see an old post from yrs ago but could not find anything recent
https://community.skuidify.com/skuid/topics/how_do_i_en_dis_able_a_custom_save_button

Thx again





Dave,

Try “enable conditions” under rendering when you click on your button in the builder. Se the condition to enable when the model has unsaved changes (model properties).

Oh that’s what the enable condition is used for :slight_smile: now I know thx

If i can bother you 1 more time, I have a little issue with the JS:



This  JS code works perfectly

 

// get your model and row

var model = skuid.$M(‘BankStatement’),

row = model.getFirstRow();

//set your shortcuts and initial variables.

returnVal = true;

$ = skuid.$;

//get the values of the formula fields you’re interested in:

var value1 = model.getFieldValue(row, ‘Ending_Balance_Calculated__c’),

value2 = model.getFieldValue(row, ‘Ending_Balance__c’);

//Create your conditional statements

if (value1 != value2)  {

returnVal = false;

}

return returnVal;

 

 

But when i try to add a 2nd condition(value 3), it does not work anymore

 

 

// get your model and row

var model = skuid.$M(‘BankStatement’),

row = model.getFirstRow();

//set your shortcuts and initial variables.

returnVal = true;

$ = skuid.$;

//get the values of the formula fields you’re interested in:

var value1 = model.getFieldValue(row, ‘Ending_Balance_Calculated__c’),

value2 = model.getFieldValue(row, ‘Ending_Balance__c’),

Value3 = model.getFieldValue(row, ‘Warning_Acknowledged__c’);

//Create your conditional statements

if (value1 != value2 && value3 === ’ ')  {

returnVal = false;

}

return returnVal;

 

 The field ‘Warning_Acknowledged__c’ is a data/time type of field.


I tried making into a checkbox, and same issue


As it’s probably a syntax error: I tried all those below, but still not working


if (value1 != value2 && value3 === ’ ') 

if (value1 != value2 && value3 === ‘Null’) 

if (value1 != value2 && value3 === Null) 

if (value1 != value2 && !value3 ) 

if (value1 != value2 && !Date.parse(value3) ) 



Any idea what I’m doing wrong?








Could just be a typo. You’re setting the var as ‘Value3’ and the evaluating ‘value3’.

I think value3 === null and value3 === ‘’ should both work.

Hi Matt , thx, but unfortunately  that did not change anything. I’m still experiencing the same issue.

am I suppose to use model.getFieldValue(row, ‘Warning_Acknowledged__c’); for a Date/time type of field?

If you cannot help me figure it out, do you advise me to create a separate post for it?

Kind of new, so not sure doing this is a recommended practice.


Thank you again


Dave,

What exactly is the issue that you’re experiencing?

.getFieldValue() is always the way to get the field value. Check out the skuid api documentation if you haven’t yet.

Matt,

I Actually did check it out and saw something for .getfield(field) and even tried that, but to no avail, so wondered if i missed something.

The issue I’m experiencing is that it saves the record and does not show popup even though conditions are met (value1 and value2 are not equal & value3 is null)

When i try with only Value1 != Value2 it works fine and i get popup as expected

For same record I no longer get the popup once i add the condition value3 is null.

Thx

have you tried (value1 !== value2 && !value3) ?

Yes , just and same result, popup not triggering :(


For testing purposes, I just removed first condition and first 2 values and only tried the value3 condition and it worked....

So I left it as condition, and added the other ones after and it worked.

No idea why, but it works lol :)

// get your model and row
var model = skuid.$M('BankStatement'),
row = model.getFirstRow();
//set your shortcuts and initial variables.
returnVal = true;
$ = skuid.$;
//get the values of the formula fields you're interested in:
var value1 = model.getFieldValue(row, 'Warning_Acknowledged__c');
value2 = model.getFieldValue(row, 'Ending_Balance_Calculated__c');
value3 = model.getFieldValue(row, 'Ending_Balance__c');
//Create your conditional statements
if (value1 === null && value2 != value3)  {
returnVal = false;
}
return returnVal;

Thank you for all your help and if you do understand the reason reverse works, I'm curious to know :)


I would like to correct my previous post.

The issue was not the order, I must have refreshed too fast...

I finally found it I have to bracket the second condition:      && (value2 != value3 ) )




// get your model and row
var model = skuid.$M('BankStatement'),
row = model.getFirstRow();
//set your shortcuts and initial variables.
returnVal = true;
$ = skuid.$;
//get the values of the formula fields you're interested in:
var value1 = model.getFieldValue(row, 'Warning_Acknowledged__c'),
value2 = model.getFieldValue(row, 'Ending_Balance_Calculated__c'),
value3 = model.getFieldValue(row, 'Ending_Balance__c');
//Create your conditional statements
if (value1 === null && (value2 != value3))  {
returnVal = false;
}
return returnVal;