Skip to main content

I have a parent record with Master-Detail child records that have a percentage field. In my Skuid editor, I have the parent record up top and a table with the child records below it. I’m need to create a rule where the child record(s) must exist and always sum to 100% when a Boolean field in the parent record is checked. I’ve been trying to do this with SF validation rules, but I’m getting nowhere. Is there some way I can do this on the client side with Skuid, or am I missing something on the validation rules side?


The SF parent validation rule I tried looks something like this if it helps:


IF( AND(

NOT(ISNEW())

, Require100percent__c = TRUE

, SumOComponents__c <> 1.0

)

, TRUE, FALSE)


Thanks for the help. Skuid is looking awesome still.

This problem does sound best handedl with field validation on the salesforce side.  So you are on the right track.  But you might also explore some client side validation that Zach suggested a few weeks ago.  The scenario is a little different, but I think you could use concepts to work toward your solution.  Here is the link:   https://community.skuid.com/t/magic-real-time-error-warning-rendering-using-javascript…

(You will have to ignore my snide product development comment)


Thanks for the direction.  Still working through this, but there is no rush.  Looks like when I add delete detail items, those aren’t processed in the same transaction, so standard SF validation doesn’t work in my case (ie, deletes, updates, and inserts are processed separately).  For instance, if I had 2 records with a 50/50 split and deleted one and changed one to 100%, validation would fail the transaction, whereas if i changed it to 80/20, it would work.  Makes sense to me at least… I’m new to SF though.

Long story short, it looks like client side is the way to go.  Need to learn some more Skuid API and javascript to make this happen I’m thinking.


Alright, I think I have it figured out.  I’d like to use the problem indicator that Skuid has in place (red bar at the top).  Couldn’t find any documentation, is there a simple way to submit issues to it?

for(var total = 0, i=0, len=skuid.model.map().IndexComponent.data.length;i<len;i++){        total +=Number(skuid.model.map().IndexComponent.dataoi].Percentage__c);}
if(total===100)
{
    skuid.model.save(.skuid.model.map().Index,skuid.model.map().IndexComponent])
}
else
{
alert(‘Index Components Must equal 100%’)
}



Hi Tom, yes there is a way to add Messages to some of the core Skuid Components, for instance Page Titles, Field Editors, or Tables.

If you give one of these Components a Unique Id, then you can pass messages to its underlying skuid.ui.Editor like this:

var pageTitle = skuid.$(‘#MyPageTitle’) // or whatever Unique Id you give it
var editor = pageTitle.data(‘object’);
editor.handleMessages(e
    { message: ‘Index components must equal 100%’, severity: ‘ERROR’ }
]);

If you change severity to WARNING, the message will be Yellow, or if you leave severity out entirely, the message will be Blue.

This is documented in this tutorial under skuid.ui.Editor, scroll down to the “handleMessages” method:

skuid.ui Object