hi im getting stuck/ confused with the correct sy...
# suitescript
s
hi im getting stuck/ confused with the correct syntax and methods on saving a sublist value client script
Copy code
rec.setCurrentSublistValue({
      sublistId: "packageusps",
      fieldId: "packagetrackingnumberusps",
      value: tracking,
      ignoreFieldChange: true,
    });
s
what is the problem, this is just the setting call?
k
@Sim Greenbaum stuck in what context and type of records
s
Can I call record.save ?
Client script trying to save tracking number to IF
b
first step is to select the line you want to edit
this step can be skipped if the user has already selected the line and is currently editing it
second step is to use CurrentRecord.setCurrentSublistValue to make your changes
you should use forceSyncSourcing if you plan on commiting the line afterwards
I also recommend not using ignoreFieldChange if any other fields use sourcing on your field
last step is commiting the line with CurrentRecord.commitLine
as with the first step, you shouldnt commit the line if the user will make additional changes to the lines themselves
s
The record is on view mode ,the user clicks a button that fires the script
At the top im calling record.load , getting data , using data to make api call , then need to save the tracking nubmer . If I save it to the record it seems straight forward set and then save
Why for sublist some much more steps
b
if you are using dynamic mode, then the steps are the same as i gave before
dynamic mode matches the steps you do in the ui
if you are not using dynamic mode, then you just use Record._setSublistValue_
s
i needed a coffe before i start working
I tried doing it in standard mode and i get a generic error
Copy code
Uncaught SuiteScriptError {…}
instead of record.save what do you use ?
Copy code
function itemfufl(rec, tracking) {
    rec.setSublistValue({
      sublistId: "packageusps",
      fieldId: "packagedescrusps",
      line: 0,
      value: tracking,
    });
   rec.save();
  }
b
You should take a closer look at the error foe its message and code