Hi All, I'm new to SuiteScript and I'm working on ...
# suitescript
s
Hi All, I'm new to SuiteScript and I'm working on an issue, hoping someone could assist 🙂 Is there a way to set a value to a field that would trigger a client script (CS) on a Suitelet? I have a Suitelet that has a CS running on it. The CS logic is if I trigger field A on that Suitelet, other fields will be visible. With the new logic, I want to default field A to a value that would trigger that CS. I tried using field.defaultvalue & form.updateDefaultValues and it works but it just sets the default values without triggering the CS. I tried to use currentRecord module to setvalue but that didn't work either. Is there anything else I can try?
n
I'm not sure i fully understand the end goal, but if you are wanting some logic on the client script to run by default, then you could use the pageInit function inside the client script. If your field is defaulting to some value and you are wanting it to run the CS code by default then i think that would be your best bet
s
Thanks for the reply! Is it possible to run 2 CS on a suitelet at once? The CS right now is pretty huge so I'm curious if the pageInit function can go on a different CS and the Suitelet will both process the old and new one.
n
umm good question. I actually don't know. Although I don't think its really necessary. The size of your client script shouldnt be a problem. And i would say its probably best practice to keep everything for the suitelet in one anyway. If splitting it out is something you are concerned about, you could always just develop a custom module script with whatever new functionality that you want in it. Then have the 1 client script load in the custom module. Then from any of the CS entry points you can call the CM script to run specific code.
l
i think there could be multiple CS. I've seen one CS attached to record level. then another attached to form level.
n
Yeah but in SuiteP's case there isn't a record to attach the CS to. All a suitelet is, is a form
s
Understand, thank you both!