- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2023 02:37 PM - edited ‎12-12-2023 02:57 PM
Hello Community,
I've been trying to pass data via Transform script (OnBefore) to a Document ID field but I don't get any result, has anyone tried this before? I tried passing the sys ID of the record, then the table name but nothing seems to work. Here's the code I've been using:
The importSet provides the "service" value with this value we determine what table name to query, so for example if the source.service_type_code = "Cellular" then it will look for the table "u_phone" and so on.. this is addressed by a switch case syntax
var tableName = "";
var service = "";
var service_number = "";
var serv_sys_id = "";
service = source.u_service_type_code;
service_number = source.u_service_number;
// Assume service is a variable that holds the name of the service
switch (service) {
case "PBX":
tableName = 'u_phone';
break;
case "Conference Service":
tableName = 'u_ucb_conference_service';
break;
case "Cellular":
tableName = 'u_phone';
break;
case "IST Services":
// code block for IST Services
break;
case "Data Network Rech":
tableName = "u_ucb_data_network_services";
break;
case "Other Voice Services":
tableName = 'u_phone';
break;
case "Centrex":
tableName = 'u_phone';
break;
case "UCBackup":
// code block for UCBackup service
break;
case "Security Video":
tableName = "u_ucb_security_video";
break;
case "Pager":
tableName = 'u_phone';
break;
default:
// code block for unknown or invalid service
}
var gr_service = new GlideRecord(tableName);
gr_service.addQuery('name', service_number);
gr_service.query();
if (gr_service.next()) {
serv_sys_id = gr_service.getUniqueValue();
}
target.u_service_id = serv_sys_id;
Also tried with
target.u_service_id.table_name = tableName;
target.u_service_id.parent = serv_sys_id
but still nothing works
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-06-2024 07:10 AM
The key is to check the dependent field of the document id field.
Open the dictionary of the document_id type field and check the dependent field set for it.
Then you can use the following example to update the field:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-06-2024 07:10 AM
The key is to check the dependent field of the document id field.
Open the dictionary of the document_id type field and check the dependent field set for it.
Then you can use the following example to update the field: