UI Builder - Unable to clear a column value through data resource

thomaskennedy
Tera Guru

I’m running a client script to make two updates to a Device record. One update is captured as expected, but the other is not done. There is no error message or anything to indicate what the problem is.

To start, the Device record has Status of “Active” and Checked Out To of “Bill”. The columns are u_status (Choice) and u_checked_out_to (String).

find_real_file.png

When I create a Service Request and save it, that should do as follows, in this order:

  1. Save the Device record with a blank for Checked Out to and “En Route for Service” for Status.
  2. Create a Service Request record and redirect the user.

For troubleshooting I have #2 rem’d out in my client script, so I won’t show that.

find_real_file.png

find_real_file.png

What actually happens is that Status is updated but Checked Out To is not.

The client script:

find_real_file.png

The result is that although the Device is now en Route for Service, it still has the name of the person it was last checked out to.

find_real_file.png

But if I set Checked Out to to a space it works fine.

// First, update the device to set status to "En Route For Service" and 
// clear the checked-out-to column.
const checkedOutTo = " ";
const status = "en_route_for_service";
var query = `u_checked_out_to=${checkedOutTo}^u_status=${status}`;
var payload = {
        "table": "x_acso_rf_poc_device",
        "recordId": api.context.props.deviceSysid,
        "templateFields": query,
        "useSetDisplayValue": false
};

find_real_file.png

I also tried this:

const checkedOutTo = null;
const status = "en_route_for_service";

But that just sets it to "null".

The status column has no default value and there are no related business rules.

Can anyone suggest what to try next?

1 ACCEPTED SOLUTION

Marc Mouries
ServiceNow Employee
ServiceNow Employee

In server-side scripting, the syntax to reset a value is to set the value to "NULL". You may want to try:

const checkedOutTo = 'NULL';

 

Hit the 👍 Helpful or Accept link ↓ if this answer brings you closer to achieving your goal

View solution in original post

2 REPLIES 2

Community Alums
Not applicable

Hi,

Can you construct your "query" value as below and try?

var query = 'u_checked_out_to=' + '';

query += 'u_status=' + 'en_route_for_service';

 

thanks

Marc Mouries
ServiceNow Employee
ServiceNow Employee

In server-side scripting, the syntax to reset a value is to set the value to "NULL". You may want to try:

const checkedOutTo = 'NULL';

 

Hit the 👍 Helpful or Accept link ↓ if this answer brings you closer to achieving your goal