<@UAA1TMMTR> I think I'm just going to test if the...
# suitescript
j
@Albert Margarit (NS Eng Lead) I think I'm just going to test if the field exists instead. Really I just need to know if certain fields are present.
👍 1
e
How about using the &xml=T trick via the URL and reading the XML. The first XML node contains all the fields available...
j
This is in script though. For context, I'm working on a script to do bespoke optimistic locking for records that don't have it built in. Unfortunately, I need to reference the last modified date, which is a field that doesn't always use the same field id (sometimes it is "lastmodified" and sometimes "lastmodifieddate")
So my users can be warned BEFORE saving that something changed, to give them a chance to make a note of their changes
already have it working in SS1, just converting to SS2
e
Yes you can do it in script by using N/https module and navigating to the URL for the specific record you need to check fields for. Using the GET method of the https module just read the response back as XML and then use the N/xml module to parse the XML for the fields.
j
my getField() idea failed. The last modified fields come back as null with getField on the currentRecord
sigh
@Albert Margarit (NS Eng Lead) apparently rec.getField({fieldId: 'lastmodified'}) is null if rec is from currentRecord 😞 But works if I load the record using record.load
a
This is in a beforeSubmit?
j
pageInit in a SS2 custom form script
a
uh. And the record is in edit mode (not "new" mode), right?
j
Correct. Here's a sample script:
Untitled
Output:
message has been deleted