I am trying to set the due date of a request to a user variable

CatchTheFletch
Tera Contributor

I am trying to set the request due_date variable to a date variable the user picks on a form. I can't seem to get it to change on submission. I setup an onsubmit script trying to change it and it didn't work. I set a run script in the workflow and it didn't work. The goal is that the task sets its due date as the request due date which should be set to what the user inputs on the form but I can't seem to get it to get that value.

Thanks in advance for any help.

 

Edit:

I guess the screenshots are broken. The run script I tried is currently this:

current.due_date = current.variables.desired_due_date;

But I have done a couple of variations with no success.

The onsubmit I tried was this:

function onSubmit() {
    //Type appropriate comment here, and begin script below
    var desired = g_form.getValue('desired_due_date');

    g_form.setValue('due_date', desired);
}

1 ACCEPTED SOLUTION

Aman Kumar S
Kilo Patron

Hey @CatchTheFletch ,

If you are trying to populate Request's due date(and not RITM), then you will need to glide the request record to update.  

Try below script in your run script activity:

var reqGR = new GlideRecord("sc_request");
reqGR.get(current.getValue("request"));
reqGR.setValue("due_date", current.variables.desired_due_date);
reqGR.update();

 

Feel free to mark correct, If I answered your query.

Will be helpful for future visitors looking for similar questions 🙂

Best Regards
Aman Kumar

View solution in original post

9 REPLIES 9

Aman Kumar S
Kilo Patron

Hey @CatchTheFletch ,

If you are trying to populate Request's due date(and not RITM), then you will need to glide the request record to update.  

Try below script in your run script activity:

var reqGR = new GlideRecord("sc_request");
reqGR.get(current.getValue("request"));
reqGR.setValue("due_date", current.variables.desired_due_date);
reqGR.update();

 

Feel free to mark correct, If I answered your query.

Will be helpful for future visitors looking for similar questions 🙂

Best Regards
Aman Kumar

That resolved that issue but I guess I was mistaken in thinking my RITM and Task would inherit that due date from it. Is there a way to make them get the same due date from the user submitted one?

No, you will have to manually set it.

There are business rules to copy propagate values but I think this field is particular to some catalog item, so better to keep it in workflow.

 

Feel free to mark correct, If I answered your query.

Will be helpful for future visitors looking for similar questions 🙂

Best Regards
Aman Kumar

That is correct. I am only worried about this particular catalog item. I want to know how to get the ritm and task to put the desired due date in as the due_date variable.

For RITM you can just simply put in run script or you can also use "Set Value" activity in workflow

current.due_date = current.variables.desired_due_date;
current.update();

 

For catalog task, when you are creating catalog task using "create catalog task" workflow activity, just add one line

task.due_date = current.variables.desired_due_date;

 

 

 

Best Regards
Aman Kumar