- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2024 09:53 AM
Hi Everyone, I am creating my first UI Action button that is on the problem task form named 'Copy to Problem'. With that button, when the user clicks on it it would then copy the fields from the problem task to what I believe is considered the parent Problem. Here are the mapping that were provided to me along with some instructions:
Create a new UI Action (a button labeled "Copy to Problem") on the PTASK form. This will copy fields from the PTASK to the parent PRB, using the following mappings:
PRB Problem Statement | PTASK Short Description
PRB Description | PTASK Description
PRB Analysis Information > Workaround | PTASK Analysis Information > Workaround
PRB Analysis Information > Cause Notes | PTASK Analysis Information > Cause notes
PRB Analysis Information > Fix notes | PTASK Analysis Information > Proposed fix notes
PRB Summary > Summary | PTASK Analysis Information | Summary
PRB Analysis Information > Contributing factors | PTASK Analysis Information > Contributing factors
And here is my script:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2024 12:11 PM
Hello @MayrelCerero ,
Try the below logic inside your UI Action script, It should works fine. I have tested it in my PDI working fine.
Just map your fields accordingly as per your requirement.
function copyToProblem() {
gsftSubmit(null, g_form.getFormElement(), 'copy_to_problem');
}
if (typeof window == 'undefined')
updateData();
function updateData() {
var probsysid = current.problem;
var problemTask = current.number;
gs.info("ProbSysID:" + probsysid + ":ProblemTask:" + problemTask +":ProbTaskSD:"+current.short_description);
var problem = new GlideRecord('problem');
problem.addQuery('sys_id', probsysid);
problem.query();
if (problem.next()) {
problem.short_description = current.short_description;
problem.description = current.description;
problem.workaround = current.workaround; // replace your fields
problem.summary = current.summary;// replace your fields
problem.update();
}
action.setRedirectURL(current);
}
Below are the screenshots:
Please Mark My Answer as Helpful and Accept as Solution, if you find this article helpful or resolves your issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2024 12:11 PM
Hello @MayrelCerero ,
Try the below logic inside your UI Action script, It should works fine. I have tested it in my PDI working fine.
Just map your fields accordingly as per your requirement.
function copyToProblem() {
gsftSubmit(null, g_form.getFormElement(), 'copy_to_problem');
}
if (typeof window == 'undefined')
updateData();
function updateData() {
var probsysid = current.problem;
var problemTask = current.number;
gs.info("ProbSysID:" + probsysid + ":ProblemTask:" + problemTask +":ProbTaskSD:"+current.short_description);
var problem = new GlideRecord('problem');
problem.addQuery('sys_id', probsysid);
problem.query();
if (problem.next()) {
problem.short_description = current.short_description;
problem.description = current.description;
problem.workaround = current.workaround; // replace your fields
problem.summary = current.summary;// replace your fields
problem.update();
}
action.setRedirectURL(current);
}
Below are the screenshots:
Please Mark My Answer as Helpful and Accept as Solution, if you find this article helpful or resolves your issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2024 09:48 AM
Thank you so so much for your help! Your script fixed the issues I ran into before. I appreciate it! 😀
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2024 09:49 AM
Thank you. Please Mark my Answer as Helpful.