Trying to update a field on the Parent Record usin...
# suitescript
s
Trying to update a field on the Parent Record using UE script on the child record. The goal is to use
record.submitFields(options)
but it needs to know the record type of the parent record. Do I have to use
search.lookupFields(options)
or is there a better way to source the record type of the parent record?
s
I am not sure why you would not already know the record type of the parent in your script?
w
You might be able to look it up using SuiteQL with the field Id.
s
I’m new to scripting, so I probably don’t fully understand how it all flows. When my custom record is updated, there’s a field that sets the “parent record”. That’s filtered to any transaction. However, when I’m trying to submitFields it requires a specific record.Type enum.
Copy code
const TXN_REC_TYPE =
      REC_TYPE !== "customrecord_crd"
        ? REC_TYPE
        : search.lookupFields({
            type: search.Type.TRANSACTION,
            id: TXN_REC_ID,
            columns: "type",
          });
Copy code
record.submitFields({
        type: TXN_REC_TYPE,
        id: TXN_REC_ID,
        values: {
          [TXN_CONTENT_FLD]: xmlAsString,
        },
      });
w
If this script only is deployed on a single recordtype you probably know which recordtype you need to update. IE customrecord_your_parent_record
s
Yes, but unfortunately, I need to update a field if 1) Parent Record is updated; 2) Update occurs on the child record (attach/detach)
w
If you need the transaction type, salesorder, invoice etc... Then I don't know of a better way.
👍 1
Is there a problem with search.lookupFields?
s
Sounds like the main issue all the differences between what
type
or
recordtype
in a search returns vs the record.Type enumeration. If this userEvent is only applied to the child record, then I do not believe you will catch changes that happen at the sublist level of the parent record.