We have a script that copies an estimate, and in s...
# suitescript
d
We have a script that copies an estimate, and in some cases changes the subsidiary. This worked perfectly fine up until recently, the script at that point hasn't been touched for 5 months, when setting the entity after changing the subsidiary gives an
UNEXPECTED_ERROR
. Setting the entity is required since changing the subsidiary empties the entity field. I know that the entity field is sort of filtered on entities that have the subsidiary on the transaction as primary subsidiary or have a CSR with that subsidiary and I think this is what is causing the issue even though there is a CSR between the entity and the subsidiary I am trying this with. Does anyone know a solution to this?
b
this is supposed to work the opposite, the entity limits the selections for the subsidiary
lots of fields are dependent on subsidiary, i would expect that changing the subsidiary should unset all those other fields
it might work if the new subsidiary has the same restrictions as the original, but i wouldnt trust it
the behavior in the ui is to unset dependent fields when the subsidiary changes and thats the behavior I would script around
it might even be worse for you in that copying an existing transaction makes the subsidiary field view only and unchangeable
general warning, dont expect to do things in script that you cant in the ui
d
yes absolutely, but i kinda can do this in the ui. when i use "make copy" and then change the subsidiary with the advanced field help extension the transaction saves just fine. no funny business with unsetting the entity.
but the biggest issue i have with this is that this script was working perfectly fine for months on end, and now i am suddenly getting this error
b
i dont think using an extension (essentially changing the field via javscript) counts
d
okay then let me rephrase my question. is there a way to copy an existing estimate to a different subsidiary?
b
no, do the normal thing of creating an new estimate and copying the field you want via script