The CreatorCon Call for Content is officially open! Get started here.

Cannot populate documentID using transform map script

GM5
Giga Guru

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

1 ACCEPTED SOLUTION

DK44
Tera Expert

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:

gr.source_id ='f59002631b9dd6106e58dce3b24bcbd4'; //Populate the document_id field with the sys_id of the record you want to populate it with.
gr.source_table = 'pm_project' // Make sure that the dependant field is populated with the name of the table related to the sys_id you are adding.

View solution in original post

1 REPLY 1

DK44
Tera Expert

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:

gr.source_id ='f59002631b9dd6106e58dce3b24bcbd4'; //Populate the document_id field with the sys_id of the record you want to populate it with.
gr.source_table = 'pm_project' // Make sure that the dependant field is populated with the name of the table related to the sys_id you are adding.