Re: Mass Updating Existing Template (112 Views)
Reply
Occasional Contributor
KK_1985
Posts: 4
Registered: ‎05-08-2014
Message 1 of 7 (220 Views)
Accepted Solution

Mass Updating Existing Template

Hi All,

 

We want do a mass update of "Refresh Fields"  in all existing Templates within SM.

 

BackGround:

We have modified couple fields from DataDict and restricted them to appear in Templates. If we click on Refresh Fields its appearing for Individual Template, but there are more than 1000 Custome Templates in our evvironment.

 

We tried doing a rtecall to Template.updateDisplay, but its not working

 

If anybody is aware of how to do it? What is the syntax?

Please use plain text.
Occasional Advisor
JanetLC
Posts: 9
Registered: ‎06-05-2012
Message 2 of 7 (179 Views)

Re: Mass Updating Existing Template

I'm not sure there is a simple way to do this. By calling the RAD directly you are missing a key piece of the functionality.  The templateRefreshFields Process does some basic setup first. It then executes a JavaScript to get the latest list of fields to be used in the Template. Then it executes the RAD. After that you would need to save the record (something the RAD doesn't do either). I'm assuming you are trying this with Mass Update so that would be doing the save.

 

You will probably need to call the process from someplace else, perhaps a custom option on the list, a JavaScript routine or loop through a Wizard. There are examples of calling se.call.process in the Script Library. A "wrapper JS call" from mass update to call the process may work.

 

Maybe someone else has a better idea. It is certainly something that would make a nice enhancement to the Template utility.

Please use plain text.
Honored Contributor
Piku
Posts: 3,708
Registered: ‎06-17-2010
Message 3 of 7 (167 Views)

Re: Mass Updating Existing Template

Hi,

Here you can try to write a JS which will traverse each template and execute the display option 'getfields' by using like doAction('getfields') and then execute the doAction('save'). Try it starting for single template without loop, if works then make it using loop for all the templates.

hth.
Please use plain text.
Occasional Contributor
KK_1985
Posts: 4
Registered: ‎05-08-2014
Message 4 of 7 (141 Views)

Re: Mass Updating Existing Template

Hi Piku,

 

This is working for one record.

 

Pasting the JS created for the same purpose. But i dont see its picking up next record from the template table.

 

function TempUpdate()

{

var

i=0;

var

maxcnt=3;

var

tname="probsummary";

var

temp=newSCFile("Template");

//var iname="\"Helpdesk - opening IM\"";

//print(" iname "+ iname);

do

{

var IncRec=temp.doSelect("tablename=\""+tname+"\"");

print("rcsucces"+ RC_SUCCESS);

//var IncRec= temp.doSelect("name isin {"+iname+"}");

print("Temp name: "+ temp.name);

print("IncRec "+ IncRec);print("rcsucces"+ RC_SUCCESS);

if (IncRec ==RC_SUCCESS)

 {temp.doAction("getfields");

temp.doAction("save");

i=i+1;print("i val"+ i);

}}while(temp.getNext()== RC_SUCCESS && i<maxcnt);print("Done Thanks");

}

Please use plain text.
Honored Contributor
Piku
Posts: 3,708
Registered: ‎06-17-2010
Message 5 of 7 (120 Views)

Re: Mass Updating Existing Template

Hi,

Happy to see you designed the JS.

Here issue is because you are selecting the record inside the while loop and every time it will restart from same place that is first record.
Hence put your 'doselect' statement out of 'do' loop.

hth,
Please use plain text.
Occasional Advisor
yogesh15dd
Posts: 11
Registered: ‎10-15-2012
Message 6 of 7 (112 Views)

Re: Mass Updating Existing Template

Hi Krishna,

 

You may try the below,

 

function TempUpdate()
{
var i=0;
var maxcnt=3;
var tname="incidents";
var temp=new SCFile("Template");


var IncRec=temp.doSelect("tablename=\""+tname+"\"");

if (IncRec == RC_SUCCESS)

{

do
{
//temp.doAction("getfields");
//temp.doAction("save");
print(i);
i=i+1;

} while (temp.getNext()== RC_SUCCESS && i<maxcnt)



}

}

 

Thank You

Yogesh

 

Please add kudos, if this works ..:)...

Please use plain text.
Occasional Contributor
KK_1985
Posts: 4
Registered: ‎05-08-2014
Message 7 of 7 (111 Views)

Re: Mass Updating Existing Template

Thanks Piku, the does achieve the solution !! Thanks for your help

 

function

TempUpdate()

{

var

i=0;

var

maxcnt=10;

var

tname="probsummary";

var

temp=newSCFile("Template");

//var iname="\"NAS - Personal\",\"Reconciliations - Logging IM\"";

//print(" iname "+ iname);

//var IncRec= temp.doSelect("name isin {"+iname+"}");

var

IncRec=temp.doSelect("tablename=\""+tname+"\"");

if

(IncRec == RC_SUCCESS)

{

do{//var IncRec= temp.doSelect("tablename=\""+tname+"\"");// print("rcsucces"+ RC_SUCCESS);print("Temp name: "+ temp.name);print("IncRec "+ IncRec);print("rcsucces"+ RC_SUCCESS);

temp.doAction

("getfields");

temp.doAction

("save");

i

=i+1;

print

("i val"+ i);

}

while(temp.getNext()== RC_SUCCESS && i<maxcnt);

}

print("Done Thanks");

}

Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation