I want to get the details from the request item description Field to sctask Field.

Barathk
Tera Contributor

Hi Team,
I want to get the details from the request item description Field we have the below details and that need to be copy to the sctask new Fields.
I have all the details in request item description like,

What is your contractor's personal email address?: sfsd@mail.com
What start date would you like for this contractor?: 2024-07-29
What end date would you like for this contractor?: 2024-08-10
Will your contractor need a badge?: Yes

I have created new Field in sctask table PersonalEmail.
I want to get the personal email details from the request item description to the PersonalEmail Field.
like , I want to get some other details also for the same.

1 ACCEPTED SOLUTION

Sandeep Rajput
Tera Patron
Tera Patron

@Barathk You can create an onBefore insert business rule on your SC task and keep the following script in the business rule script field.

(function executeRule(current, previous /*null when async*/) {
    // Your code here
   var descriptionArry = current.request_item.decription.split('\n');

for (var i = 0; i < descriptionArry.length; i++) {
    var itemArray = descriptionArry[i].split(':');
    if (itemArray.length == 2) {
        gs.info('Question is ' + itemArray[0]);
        gs.info('Answer is ' + itemArray[1]);
       //Set your fields here.
    }

}
})(current, previous);

Hope this helps.

 

View solution in original post

1 REPLY 1

Sandeep Rajput
Tera Patron
Tera Patron

@Barathk You can create an onBefore insert business rule on your SC task and keep the following script in the business rule script field.

(function executeRule(current, previous /*null when async*/) {
    // Your code here
   var descriptionArry = current.request_item.decription.split('\n');

for (var i = 0; i < descriptionArry.length; i++) {
    var itemArray = descriptionArry[i].split(':');
    if (itemArray.length == 2) {
        gs.info('Question is ' + itemArray[0]);
        gs.info('Answer is ' + itemArray[1]);
       //Set your fields here.
    }

}
})(current, previous);

Hope this helps.