SuiteScript pattern: When transforming an SO to an...
# suitescript
c
SuiteScript pattern: When transforming an SO to an IF, default NS behaviour is to copy all items from the SO onto the IF, I then have to write a function to remove the items that I don't want fulfilled (depending on the requirements/criteria). There is an option in NS to make a transform copy over zero items but enabling that would be a massive change for users and probably undesirable. Question: Has anyone found a way to record.transform() an SO with a specific list of items to add to the IF or is removing the unwanted items from the IF the only way to achieve this with default NS settings? If this is the only way, I'm doing the IF item removal THEN saving the transformed IF record if the item removal was successful; what do you think of that pattern? 1. Transform SO to IF 2. Remove excess items from IF 3. Save transformed record (Item Fulfilment).
s
removing excess items is usually only a line or two of code [NFT] but you might also see if any
options.defaultValues
trickery could be applied during your
record.transform()
c
defaultValues is what i was thinking but not being able to pass in your own list of values means it's a no-go
Not a massive issue, just curious if there were any standard patterns beyond what I'm doing.
c
You have to transform then modify the lines like you're doing. It gives you the record completely transformed w/ what it expects to be there so if you're modifying the lines you have to do it yourself there's no default value to specify this. The default values are pretty limited in what they do. The only other option is just create the IF yourself without the transform.
👍 1