Hi Team, I want to unselect the values in the Mul...
# suitescript
a
Hi Team, I want to unselect the values in the Multiselect field while making a copy. I have used the below code to unselect/remove the values in that field. invoiceRecord.setValue({ fieldId: 'custbody_related_je', value: []}); But still, I can see the values are present in that field, and it is not making the value null. Can anyone please help me with this? Any suggestions or tips to resolve this issue?
Can anyone please help me with this?
a
you haven't provided enough information I'm guessing you're using the record module and object and what you need to be using is the ui/serverWidget module and the field object
a
Here is the part of the code I'm using. if (context.type === context.UserEventType.COPY) { var invoiceRecord = context.newRecord; var getSubsidiary = invoiceRecord.getValue("subsidiary"); var getNotifyCustomer = invoiceRecord.getValue("custbody30"); var getWithHoldTaxExpenses = invoiceRecord.getValue("custbody_amount_paid_from_je"); var getRelatedJEs = invoiceRecord.getValue("custbody_related_je"); log.debug("In Before Load Body Details", {getSubsidiary, getNotifyCustomer, getWithHoldTaxExpenses, getRelatedJEs}); if (getNotifyCustomer && getWithHoldTaxExpenses && getRelatedJEs.length>0) { invoiceRecord.setValue("custbody_amount_paid_from_je", null); invoiceRecord.setValue({ fieldId: 'custbody_related_je', value: []}); /// Making unselect values in this field. log.debug("context","setting null to related je and amount field"); } } Please check the code and let me know any thing I miss in the above code.
a
your code is fine for nulling the multiselect field both of these work
Copy code
invoiceRecord.setValue({ fieldId: 'custbody_related_je', value: [] });
invoiceRecord.setValue({ fieldId: 'custbody_related_je', value: null });
this code however doesn't appear to valid SS 2.x
Copy code
invoiceRecord.setValue("custbody_amount_paid_from_je", null);
setValue
takes a object single object param with
fieldId
and
value
keys - which you're doing in the other
setValue
what do you mean by this "But still, I can see the values are present in that field, and it is not making the value null."
you can SEE it? in your suitescript context? after the script runs they're still selected? they will remain visible as OPTIONS but UNSELECTED usually depending on the number of things that could populate that multiselect field
proof that your code works and the values are no longer set
are you hitting the
log.debug('context' , 'setting null to related je and amount field')
?
a
Hi @Anthony OConnor, Thank you for the reply. Sorry for the delay in reply. As I was a little busy with other stuff. you can SEE it? In your suite script context? after the script runs, are they still selected? See screenshot 1 What do you mean by this "But still, I can see the values are present in that field, and it is not making the value null." Answer: I mean the values are still showing in the field after making the make copy of the record. See screenshot 2
a
yeah if you'd have told me this was a before load UE 2 months ago we'd have been done in 5 minutes
you can't edit record values in a before load
you'll need to use a client script on pageInit