Skip to main content

Hi,

I’m working on a validation issue where the field that needs to be validated has to be compared to a field from another model on the save button. I am pretty sure this has to be done with a snippet code. I wanted to see if someone can point me in the right direction.

-Thanks,
Adam N

Any reason you can’t use a Salesforce validation rule?


The page I’m working with is a Skuid Page that we used to replace the salesforce page.


This issue is when a sales rep creates a “New Sales Order” the field that needs to be validated is the “Customer” field. That field need to reference another field in the billing object so if that customer has a past due balance my sales rep will get an error message stating such on the save action.


I hope this makes sense.



var model = skuid.model.getModel(‘Billing’),row = model.Days_Since_Billing_Date__c();

if (row.Days_Since_Billing_Date__c >= 75) {
  alert(“I am an alert box!”);
} else {
  save()
}



This is the code I started. 


I’d favour using a server side validation rule. Is the billing object child to Account as Master? If so, use a rollup on Account and create the validation rule on Sales Order.


You could use the Action Framework “Branch” Action Type, with an “If-True Action” that displays an error message, otherwise the Action sequence can continue to a “Save Models” Action.

The “Formula” for the Branch Action would be something like this:

{{{$Model.Billing.data.0.Days_Since_Billing_Date__c}}} >= 75

You could also / alternatively define an Enable Condition on the Save button that causes the button to be disabled if the Days Since Billing Date >= 75.


I dont see the branch action type. 


Nvm. I found it. Let me try it. 


Zach, I was not able to find that  “Branch” Action Type, or the “If-True Action”. Ca you help please?


Here you go.


To create True Branch


True Branch


False Branch