cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Batch copy field A to field B for all items found by a query

nxpet
13-Aquamarine

Batch copy field A to field B for all items found by a query

Hi, I want to copy the data of a field A to field B for a big number of items. Both fields are part of the same item. The batch copy action should be performed for all items that are found for a certain query. Can this be done be a command line option? Can you help me on that, since I am not familiar with command line options yet. Thanks!

 

Timo

ACCEPTED SOLUTION

Accepted Solutions
ascott
17-Peridot
(To:nxpet)

Hi Timo,

 

A scheduled trigger is likely what you want. Set the trigger type to "Manual" and then on the query tab, you can select the query that returns all the items to run against. You will have to create a trigger script to facilitate the copy from one field to another.

Essentially:

//Gets the arguments for schedule trigger

stb = bsf.lookupBean("imScheduleTriggerArgumentsBean");

//This gets list of issues return by configured query

itemIds = stb.getIssues();

You would then just have to loop through the itemIds, copying the value from Field1 to Field2 and performing the required error checking. There should also be an option on either Serverbean or EnvironmentBean to "commit" your transaction...I would recommend you do that every 50-100 items - so they don't remain "locked" and inaccessible to other users. (Also a good idea to run it during off-peak hours)

 

For more info see the "Event Trigger Java Documentation" available on your Integrity Server's homepage. (Open <server host>:<port> in a web browser.

Hope this helps!

-Andrew

 

 

View solution in original post

2 REPLIES 2
ascott
17-Peridot
(To:nxpet)

Hi Timo,

 

A scheduled trigger is likely what you want. Set the trigger type to "Manual" and then on the query tab, you can select the query that returns all the items to run against. You will have to create a trigger script to facilitate the copy from one field to another.

Essentially:

//Gets the arguments for schedule trigger

stb = bsf.lookupBean("imScheduleTriggerArgumentsBean");

//This gets list of issues return by configured query

itemIds = stb.getIssues();

You would then just have to loop through the itemIds, copying the value from Field1 to Field2 and performing the required error checking. There should also be an option on either Serverbean or EnvironmentBean to "commit" your transaction...I would recommend you do that every 50-100 items - so they don't remain "locked" and inaccessible to other users. (Also a good idea to run it during off-peak hours)

 

For more info see the "Event Trigger Java Documentation" available on your Integrity Server's homepage. (Open <server host>:<port> in a web browser.

Hope this helps!

-Andrew

 

 

nxpet
13-Aquamarine
(To:ascott)

Hi Andrew, thanks for your help. I will try your solution the next time I do have to copy lots of fields. This time I solved it by copying manually everything in a 3-hours session 😞 But next time I will spend some time in this trigger script.

 

Timo

Announcements


Top Tags