Hi I'm trying to get a fieldchanged client script ...
# suitescript
r
Hi I'm trying to get a fieldchanged client script for vendor change on a purchase order , the function is not recognizing any changes to vendor , if I change another field it logs the correct field name. Is there something specifically to the vendor that the fieldchanged will not register? Thanks.
e
You'll likely need to share your code
coke 1
r
var fieldChanged = function (context) { var fieldId = context.fieldId, currentRecord = context.currentRecord; log.debug('currentRecord', currentRecord); log.debug('fieldId', fieldId); };
e
Does the value of the Vendor field actually change? Or is it stuck on one value? Do you have any code running on
validateField
, either in this script or any other Purchase Order scripts?
r
im changing vendor in a new purchase order before it is saved , the fieldId does not log on a vendor change, it logs on other field changes
There are no other client scripts
e
I'm asking if the new value sticks when you try to change the field.
To answer your question directly though: no, there is nothing special about the
entity
field on a transaction; it should fire
fieldChanged
like anything else.
r
yes if i would save it saves
e
If the new value didn't stick, that would indicate a
validateField
is returning
falsy
somewhere
but if it sticks, then I'm not sure what's happening. You could try to add both
validateField
and
postSourcing
handlers as well, and see if those fire
r
Those do not pick up the change in vendor as well.
e
FWIW, in my account this code correctly logs to the console, but does not log to the Execution Log when I change the Vendor field on a Purchase Order:
Copy code
/**
 * @NApiVersion 2.1
 * @NScriptType Client
 */
define([], () => ({
  fieldChanged: (context) => {
    console.log(`Field ID: ${context.fieldId}`)
	log.debug({ title: 'Field ID:', details: context.fieldId })
  }
}))
r
I just tried console.log and it didnt log
e
Not sure what to say if other fields work fine and nothing else is deployed to the PO on the client side (workflows or scripts).
r
i didnt check on workflows
Thanks i think i see something in a workflow.
1