Change Task Copy Record functionality from Complex Mass Update using

Am trying to mimic Copy Record functinality of Change Task from Complex Mass Update using rad function. Planning to use the code to create duplicate of task(s) within same change Record. I know there are other ways to accomplish this. i wanted to know if it is possible from Comples Mass update. I have tried below code. I keep getting error - "The Phase does not exist. Record cannot be processed."

HP Service Manager version 9.34

Instructions to be executed ONCE:-

$L.rci=rtecall("rinit", $L.rc1, $L,objt, "object");$L.rcs=rtecall("select", $L.rc2,$L.objt, "filename=\"cm3t\"");$L.rci=rtecall("rinit", $L.rc1, $L,prnt, "cm3r");$L.q="number=\"" parent.change in $file "\"";$L.rcs=rtecall("select", $L.rc2,$L.prnt, $L.q)


Instructions for each record(tasks):-

$L.rci=rtecall("rinit", $L.rc.rinit, $L.newtask, "cm3t");$L.flg=rtecall("recdupl", $L.rc, $L.newtask, $file)

cleanup(number in $L.newtask);category in $L.newtask="Implementation";current.phase in $L.newtask="Waiting"

$L.void=rtecall("callrad", $L.rc, "", {"record", "second file", "boolean1", "cond.input", "target.file"}, {$L.newtask, $L.objt, true, false, $L.prnt}, false)


Phase and category are present in the tables and phase is defined under category. I have tried giving invlaid phase values, still same error. I have also tried resetting phase pointer for no use.

Please help me if I have missed any pre-rad statements before the calling rad.

I would be intrested to know if at all it is possible to duplicate tasks from comples mass update. So that, I can give up trying this approach.

Any help is much appreciated.


  • I'm assuming you are aware that you have several typos in your syntax?

    I'm not quite sure I'm following what you're trying to do.

    In your first step, you initialize the cm3t Object record, and ONE parent change (regardless of the number of tasks you have in your mass update list?  Are they all the same parent?  If they're different parents, then you're only getting the parent for the _first_ Task.  You're executing that code at the start of your Mass Update, not at the start of each record...)

    Then, in your second step, you initialize an empty cm3t record ($L.newtask) using recdupl.  I don't use that one much (I've never tried what you're doing) but the help document for recdupl states: "The update and delete operations cannot be performed against $targetfile." So I'm not sure if that function will do what you're trying to do.  Maybe you want 'fduplicate'?

    Next, you try clearing out the number, set the category and set a phase for your copied task.  Then you try calling a RAD call within the same thread (and I'm not sure that will work correctly either.  When you make the RAD call all of your variables will change within that RAD function, throwing off your current $file variable that you're trying to use from the complex update.  Then the system loses its place when that RAD finishes out).

    But maybe take a step back... why are you trying to do this?  What is the driver for taking a list of tasks from whatever your base query was and making several duplicate copies of the same Task?  What's the business need behind this code attempt?

  • Hi Jacob,

    Thanks for looking into this. Forgive me for the typos, I couldn't copy paste the actual code tested so had to re-type everything.

    Let me first give business need/scenario:

    We have a scenrios where there is need to have hundreds of change tasks (300 - 500) within same change record. All the tasks are similar except for one line in description. So, I create one task and select Copy Record option 500 times to create duplicates.

    To save time on manually selecting Copy Record option. we thought to automate "Copy Record" option using complex update. We came to know that Copy Record option simply copies data from existing task and calls rad to create the new task.

    First step was to try writing complex update code to duplicate one or two tasks. And then use it to create 500 tasks. However, we are stuck at first step. we thought it will be pretty straight forward.

    Basically, we created 1 or 2 tasks under same parent change. Selected View All Tasks for the change, selected the two tasks for mass update and  tried to duplicate them under same parent change using complex update code.

    Regarding recdupl, yes we can use fduplicate also. Since $L.newtask was temporary thought it doesn't matter. I have tired copying fileds individually also without using fduplicate or recdupl. Will use fduplicate going forward.

    I don't know if clearing out the number is needed, just tried it to see if gets any better results. No need to set category and phase also as they are already copied in recdupl statement. This is just to show that, I have taken care of category and phase for the task. I have tried giving invalid values too.

    All the data in $file is copied to $L.newtask, so should be fine if current $file is thrown out during rad. Hopefully, for next task in the mass update list, $file will again get correct data(?).

    Basically, our goal is to duplicate one or multiple tasks within same parent change record using Complex Mass update.




  • Thanks for the information.

    If this is something that you intend to be repeatable, I wouldn't try to put it in the Complex Mass Update.  That puts the onus on a SysAdmin to perform a function to make this happen.  SysAdmins (should) have better things to do with their time than performing menial tasks.

    I'm not sure of a process that honestly requires 500 identical tasks (except for the description) but it's your business, not mine.  But if someone came to me with that requirement, they'd need some serious leverage and significant business justification for that.  If it's a bunch of different tasks to different teams, ok, I can understand that.  If it's a couple different teams, but the tasks are for each CI in the Change ticket, ok, I can understand that - and the tool has OOB functionality to do both of those things.  But identical copies of the same task (same team, same CIs, same dates, same actions); that doesn't sound like best practice or ITIL.

    But, assuming it _HAS_ to be done, if it's something that has to trigger regularly as part of a specific Change category, I'd move the code up a level to the cm3rcatphase record in the Auto Open Tasks section, to trigger your Tasks automatically as your change moves into a particular phase. If the same category of change requires the same task information, always these same 500 times, you could make 500 tasks Auto Open, always, every time, as a change moves in to a particular phase. 

    If that doesn't work or if that's not an option, I'd build a Script Library javascript to iterate through your tasks, and then call that from the formatctrl of your parent change, or use the formatctrl to create a schedule record and run it as a background process so that a user isn't sitting there waiting for the system to respond from 500 Open New Tasks.

    But I'd start by re-evaluating the business justification for 500 identical tasks.

  • I agree with Jacob.

    500 tasks sounds as an enormous amount so re-evaluate if that really is needed.

    Regardless if you need 2 or 500 a javascript is much easier to write and maintain. Don't use massupdate complex and rad function to this. You are only making you life harder by trying that,

    Just remember when creating the tasks to update the changePlan record.