Skip to main content

Confusing title, so I will try and be detailed. 

Basically when a user inputs information, we don’t want them to advance to the next step unless there is a child record. 

For example,  Lets say you were buying a charging plug for your phone. You need the cord that goes with it or else its useless. Our problem would be that you could need anywhere from 1 charging plug to 5. 

We do not want our users to be able to advance to the next step unless they have selected the “cord”.

My initial thought was to use a roll up summary field and count the child records and if it was greater than 0 for each row we could advance, but given that if you only have 1 row in the model, rows 2 - 5 are going to equal 0 and that wont work.

So my next trial is a set of 5 branch statements, but considering the amount of actions on the “Next” button, this is a considerable lift to use 5 separate branch logic statements to check how many rows are in the model. 


Does anyone have a potentially easier way (assuming that ramble made sense)?

I would prefer a non-code option, but would be open to it, if it is the best option. 

Thanks, 

Richard

IF({{$Model.Outlet.data.length}} == 1) {
    IF({{$Model.Outlet.data.0.of_Devices__c}} == 0) {
        return true;
     }else{
        return false;
     }
} ELSEIF({{$Model.Outlet.data.length}} == 2) {
     IF({{$Model.Outlet.data.0.of_Devices__c}} == 0 || {{$Model.Outlet.data.1.of_Devices__c}}== 0) {
        return true;
     }else{
        return false;
     }
     
} ELSEIF({{$Model.Outlet.data.length}} == 3) {
     IF({{$Model.Outlet.data.0.of_Devices__c}} == 0 || {{$Model.Outlet.data.1.of_Devices__c}}== 0 || {{$Model.Outlet.data.2.of_Devices__c}}== 0) {
        return true;
     }else{
        return false;
     }
     
} ELSEIF({{$Model.Outlet.data.length}} == 4) {
     IF({{$Model.Outlet.data.0.of_Devices__c}} == 0 || {{$Model.Outlet.data.1.of_Devices__c}}== 0 || {{$Model.Outlet.data.2.of_Devices__c}}== 0 || {{$Model.Outlet.data.3.of_Devices__c}}== 0) {
        return true;
     }ELSE{
        return false;
     }
    

} ELSE {
     IF({{$Model.Outlet.data.0.of_Devices__c}} == 0 || {{$Model.Outlet.data.1.of_Devices__c}}== 0 || {{$Model.Outlet.data.2.of_Devices__c}}== 0 || {{$Model.Outlet.data.3.of_Devices__c}}== 0 || {{$Model.Outlet.data.4.of_Devices__c}}== 0) {
        return true;
    }else{
        return false;
    } 
}


So this is within my branch statement. The actions within just simply display an error message.

I am getting an error "Cannot read property of “merges” of Null.

If i am understanding this correctly, it sounds like skuid is trying to evaluate all the merge syntax regardless of if it will be used. Does this sound correct?


You could try a model “stack”. Your first model is the primary model in your table. Then you could create a model on the child object that only displays rows that have parents in the model of your primary model. Then you could have a third model that is based on the same object as your primary model that only displays rows that have Id’ that are contained in the first model and that ARE NOT found as parents in the second model. This would give you a list of parents without children. If that model contains rows, then the user should not proceed. I have no idea if this will work, but I did something similar for a completely different scenario and after enough tinkering it worked.


Just wanted to get back to this thread, as I found a fairly simple way to do this.

So lets say you have Accounts, stores and equipment.

All stores need to have equipment and all stores have to have an account.

Create a roll-up field on Stores, that counts the number of equipment at the store

Create a Roll-up summary on account, which count’s the number of stores where the previous roll up field on store, equals 0.



Thanks for the help!


Reply