RE: How to Set a Sublist Value in a Client Script
Hi, I have child record sublist that I want to be able to manage from the parent record (both parent/child are custom records). There’s a checkbox field called “Current” on the child indicating the current child record. I want to be able to toggle this checkbox where it’s mutually exclusive among the other child records, similar to address subrecords where there can only be one default billing address and when you check one address it unchecks the other.
The way I’m trying to accomplish this is with a client script that uses validateLine. When the “Current” checkbox is set to true on a line, I iterate through all the other lines and set Current = false. The problem is the currentRecord module will allow me to set the current sublist field with setCurrentSublistValue, but it won’t let me set other sublist fields, which ordinarily would be done with setSublistValue. The currentRecord module apparently doesn’t have the latter method, and I need it for my iteration, because I need to change the other sublist lines to false when the current line is set to true by the user.
Is there a way to do this without having the setSublistField method for the currentRecord module?
Client script’s programming model doesn’t do multi line logic well. You would need to use CurrentRecord.selectLine followed by CurrentRecord.commitLine to select a line and then later commit it. Keep in mind that your client script (and sadly other client scripts) probably need to be written so that the changes to the other lines do not trigger unwanted logic.
You might also want to consider using sublistChanged instead of validateLine