I have a user event script that I'm trying to set ...
# suitescript
s
I have a user event script that I'm trying to set the address field for a transfer order
Copy code
ifRec.setValue({
        fieldId: "shipaddress",
        value: addressTxt,
      });
a
s
so does that mean it cant be changed by script?
a
you have to change the shipaddresslist
1
l
address is a list, not a field
s
is this how to create a new address
Copy code
ifRec.setSublistValue({
        sublistId: 'shipaddress',
     fieldId: 'addressee',
        line: 0,
     value: address_object.fcName
      });
what is the correct way to set a new address on the IF ? Also does override field need to be true or false "f" "F" etc
Copy code
var addressdata = ifRec.getSubrecord({
        fieldId: "shippingaddress",
      });
b
s
i have confirmed that it is saved inside the address field but the override box is still checked
b
check what the override field does in the ui
s
in the UI if the override is checked, then it will only save the form but not edit the address text if it's unchecked the form will update
b
the form will up
makes no sense
s
are trying to test me
you know what am i asking: my question is how to set the override to false in order for the
Copy code
shipaddress to be updated via script
// current code var addressdata = ifRec.getSubrecord({ fieldId: "shippingaddress", }); addressdata.setValue({ fieldId: fieldId, value: value, });
b
override does not actually control what is set on the item fulfillment
so im trying to understand what you are trying to do
your descriptions so far havent helped that understanding
s
Copy code
Check this box to disable the free-form address text field. When this field is disabled, text entered in the other address fields does not display in the Address text field.

Clear this box to allow text entered in the address component fields to appear in the free-form address text field.
so if I'm setting the fields and the override is checked it it wont update /display Address text field
b
at this point you also want to make the distinction between the addrtext field on the address subrecord and the shipaddress on the item fulfillment
they are different things
and the override checkbox is only related to the addrtext on the address subrecord
so far, your latter description of
Copy code
so if I'm setting the fields and the override is checked it  it wont update /display Address text field
makes sense for addrtext, if you are overriding the addrtext, you are setting it yourself and it shouldnt source from the address fields
s
im trying to set the address field(s) on the subrecord
Copy code
var addressdata = ifRec.getSubrecord({
        fieldId: "shippingaddress",
      });
    
      function addresList(value, fieldId) {
        addressdata.setValue({
          fieldId: fieldId,
          value: value,
        });
      }
      addresList(false, "override");
      addresList(address_object.city, "city");
      addresList(address_object.fcName, "addressee");
      addresList(address_object.stateCode, "state");
      addresList(address_object.postalCode, "zip");
      addresList(address_object.addressLine1, "addr1");
b
great, that looks like it sets fields on the subrecord
s
this code if I edit the item fulfillment in the UI the fields in the form (subrecord) are correct but the addrtext is wrong data and override is checked in addition shipaddress on the IF is wrong data
b
the override checkbox being checked is unusual, especially since you set it to false
the shipaddress on the item fulfillment not matching the address subrecord is fairly common
s
the issue is we print bol form using BOl suite app I'm not sure where it gets it address data from
b
the usual fix for the shipaddress not matching is just to unset it on the item filfillment to make it source again from the address
may or may not work for you if the override checkbox is doing something weird
the extra safe option is to set both address text related fields yourself
s
i will try that to set the address text on the subrecord also and see what happens
thanx @battk
b
your usage of the word also is concerning, the code you shared on the subrecord makes no attempt to set address related text
s
This is my updated code but the addrtext on the sub-record in the UI is still the old address and override is still true/checked which means the shipaddress doesn't change
Copy code
let addressTxt = `${ address_object.fcName }\n${ address_object.addressLine1 } \n ${ address_object.city }${ address_object.stateCode } 
      ${ address_object.postalCode } \nUnited States`
      var addressdata = ifRec.getSubrecord({
        fieldId: "shippingaddress",
      });
    
      function addresList(value, fieldId) {
        addressdata.setValue({
          fieldId: fieldId,
          value: value,
        });
      }
      addresList(false, "override");
      addresList(address_object.city, "city");
      addresList(address_object.fcName, "addressee");
      addresList(address_object.stateCode, "state");
      addresList(address_object.postalCode, "zip");
      addresList(address_object.addressLine1, "addr1");
      addresList(addressTxt, "addrtext");
b
you can try directly setting the shipaddress field
or the equivalent unsetting it, which makes netsuite source it from the addrtext
s
it worked
Copy code
ifRec.setValue({
        fieldId: "shipaddress",
        value: "",
      });