Many of you how read my post about the security proxy concept in FileNet P8 (http://justecm.de/2020/02/using-security-proxy-for-dynamic-access-control-in-filenet-p8/) asked me how to set the security proxy property values for existing documents in a bulk job without coding a external java program. In this post I will show you how to to this with a custom java script sweep action for property templates of data type string an object.
At first you need to create a new custom sweep action in the sweep management of you object store.
![](http://justecm.de/wp-content/uploads/2021/01/image.png)
Give the action a name and select “JavaScript” as the action type.
![](http://justecm.de/wp-content/uploads/2021/01/image-1-1024x275.png)
Enter the following Javascript code in the appropriate field and finish the sweep action creation.
importPackage(Packages.com.filenet.api.core);
importPackage(Packages.com.filenet.api.constants);
importPackage(Packages.com.filenet.api.exception);
importPackage(Packages.com.filenet.api.sweep);
importPackage(Packages.com.filenet.api.engine);
importPackage(Packages.com.filenet.api.property);
importPackage(Packages.com.filenet.api.util);
// Implement for custom job and queue sweeps.
function onSweep (sweepObject, sweepItems)
{
var hcc = HandlerCallContext.getInstance();
hcc.traceDetail("Entering CustomSweepHandler.onSweep");
hcc.traceDetail("sweepObject = " + sweepObject.getProperties().getIdValue(PropertyNames.ID) + "sweepItems.length = " + sweepItems.length);
// Iterate the sweepItems and change the class.
ii = 0;
for (ii = 0; ii < sweepItems.length; ii++)
{
// At the top of your loop, always check to make sure
// that the server is not shutting down.
// If it is, clean up and return control to the server.
if (hcc != null && hcc.isShuttingDown())
{
throw new EngineRuntimeException(ExceptionCode.E_BACKGROUND_TASK_TERMINATED, this.constructor.name + " is terminating prematurely because the server is shutting down");
}
var item = sweepItems[ii].getTarget();
var msg = "sweepItems[" + ii + "]= " + item.getProperties().getIdValue("ID");
hcc.traceDetail(msg);
try
{
var CEObject = com.filenet.api.core.Document (item);
var os = sweepObject.getObjectStore()
var objectId = com.filenet.api.util.Id("{5BE7719F-9B56-4183-8F5A-7D3C514FA765}");
var co = Factory.CustomObject.fetchInstance(os, objectId, null);
CEObject.getProperties().putObjectValue("SecurityTemplate", co);
CEObject.save(com.filenet.api.constants.RefreshMode.NO_REFRESH);
// Set outcome to PROCESSED if item processed successfully.
sweepItems[ii].setOutcome(SweepItemOutcome.PROCESSED,
"item processed by " + this.constructor.name);
}
// Set failure status on objects that fail to process.
catch (ioe)
{
sweepItems[ii].setOutcome(SweepItemOutcome.FAILED, "CustomSweepHandler: " +
ioe.rhinoException.getMessage());
}
}
hcc.traceDetail("Exiting CustomSweepHandler.onSweep");
}
/*
* Called automatically when the handler is invoked by a custom sweep job
* or sweep policy. Specify properties required by the handler, if any.
* If you return an empty array, then all properties are fetched.
*/
function getRequiredProperties()
{
var pnames = ['Id'];
return pnames.toString();
}
/* Implement for custom sweep policies.
* This method is not implemented because this is an example of a custom sweep job.
*/
function onPolicySweep (sweepObject, policyObject, sweepItems)
{}
The only value that needs to be adapted to your environment is in line 37 the GUID of the security proxy object that you want to pass to the documents via the sweep job and in line 39 the symbolic name of the property template in your document class.
var objectId = com.filenet.api.util.Id(“{5BE7719F-9B56-4183-8F5A-7D3C514FA765}“);
CEObject.getProperties().putObjectValue(“SecurityTemplate“, co);
So if you need to set different object values to the property templates I would recommend to create also different sweep actions. It make it afterwards a little bit more handy.
Now you can create the custom sweep job to set the object property values for all you existing documents.
![](http://justecm.de/wp-content/uploads/2021/01/image-2.png)
![](http://justecm.de/wp-content/uploads/2021/01/image-3-1024x682.png)
Select the target class on which you want to run the sweep and select our previously created custom sweep action.
![](http://justecm.de/wp-content/uploads/2021/01/image-4-1024x453.png)
Finish the creation wizard an activate you sweep job.
![](http://justecm.de/wp-content/uploads/2021/01/image-5-1024x700.png)
That’s it now you can update the property values with bulk processing. Now I want to share with you also the Java Script code to update a string property value.
importPackage(Packages.com.filenet.api.core);
importPackage(Packages.com.filenet.api.constants);
importPackage(Packages.com.filenet.api.exception);
importPackage(Packages.com.filenet.api.sweep);
importPackage(Packages.com.filenet.api.engine);
// Implement for custom job and queue sweeps.
function onSweep (sweepObject, sweepItems)
{
var hcc = HandlerCallContext.getInstance();
hcc.traceDetail("Entering CustomSweepHandler.onSweep");
hcc.traceDetail("sweepObject = " + sweepObject.getProperties().getIdValue(PropertyNames.ID) + "sweepItems.length = " + sweepItems.length);
// Iterate the sweepItems and change the class.
ii = 0;
for (ii = 0; ii < sweepItems.length; ii++)
{
// At the top of your loop, always check to make sure
// that the server is not shutting down.
// If it is, clean up and return control to the server.
if (hcc != null && hcc.isShuttingDown())
{
throw new EngineRuntimeException(ExceptionCode.E_BACKGROUND_TASK_TERMINATED, this.constructor.name + " is terminating prematurely because the server is shutting down");
}
var item = sweepItems[ii].getTarget();
var msg = "sweepItems[" + ii + "]= " + item.getProperties().getIdValue("ID");
hcc.traceDetail(msg);
try
{
var CEObject = com.filenet.api.core.Document (item);
CEObject.getProperties().putValue("DocumentTitle","This is a custom sweep action");
CEObject.save(com.filenet.api.constants.RefreshMode.NO_REFRESH);
// Set outcome to PROCESSED if item processed successfully.
sweepItems[ii].setOutcome(SweepItemOutcome.PROCESSED,
"item processed by " + this.constructor.name);
}
// Set failure status on objects that fail to process.
catch (ioe)
{
sweepItems[ii].setOutcome(SweepItemOutcome.FAILED, "CustomSweepHandler: " +
ioe.rhinoException.getMessage());
}
}
hcc.traceDetail("Exiting CustomSweepHandler.onSweep");
}
/*
* Called automatically when the handler is invoked by a custom sweep job
* or sweep policy. Specify properties required by the handler, if any.
* If you return an empty array, then all properties are fetched.
*/
function getRequiredProperties()
{
var pnames = ['Id'];
return pnames.toString();
}
/* Implement for custom sweep policies.
* This method is not implemented because this is an example of a custom sweep job.
*/
function onPolicySweep (sweepObject, policyObject, sweepItems)
{}
To use this in you environment you just need to set up the property templates symbolic name an the string you want to pass in code line 32. The rest is straight forward and you can work around the previous guide above.
Have fun with the sweeps :-).
Over and out!
great issues altogether, you just received a logo new reader. What could you suggest in regards to your put up that you made some days in the past? Any certain?
Useful info. Lucky me I discovered your site by chance, and I am shocked why this twist of fate did not came about earlier! I bookmarked it.
Definitely believe that which you stated. Your favorite reason seemed to be on the web the simplest thing to be aware of. I say to you, I certainly get annoyed while people consider worries that they just don’t know about. You managed to hit the nail upon the top and also defined out the whole thing without having side effect , people could take a signal. Will likely be back to get more. Thanks
Thanks a bunch for sharing this with all of us you really know what you are talking about! Bookmarked. Kindly also visit my web site =). We could have a link exchange agreement between us!
Thank you for the auspicious writeup. It in fact was once a enjoyment account it. Glance advanced to more added agreeable from you! By the way, how can we be in contact?
An interesting discussion is worth comment. I think that you should write more on this topic, it might not be a taboo subject but generally people are not enough to speak on such topics. To the next. Cheers
It?s hard to find knowledgeable people on this topic, but you sound like you know what you?re talking about! Thanks
Moreover, too tight clothes can cause sweat to accumulate quickly; so soft and comfortable
cotton clothes are recommended, particularly if you already have acne.
Learn more Skin Care at Amazon
This is the right blog for anyone who wants to find out about this topic. You realize so much its almost hard to argue with you (not that I actually would want?HaHa). You definitely put a new spin on a topic thats been written about for years. Great stuff, just great!
Hello! I just would like to give a huge thumbs up for the great info you have here on this post. I will be coming back to your blog for more soon.
I?d have to check with you here. Which is not something I usually do! I enjoy reading a post that will make people think. Also, thanks for allowing me to comment!
Youre so cool! I dont suppose Ive read anything like this before. So nice to find somebody with some original thoughts on this subject. realy thank you for starting this up. this website is something that is needed on the web, someone with a little originality. useful job for bringing something new to the internet!
WONDERFUL Post.thanks for share..more wait .. 😉 ?
Hi, of course this paragraph is in fact nice and I have learned lot of things from it on the
topic of blogging. thanks.
I have been absent for a while, but now I remember why I used to love this blog. Thanks , I’ll try and check back more often. How frequently you update your website?
Hello, i read your blog occasionally and i own a similar one and i was just wondering if you get a lot of spam feedback? If so how do you protect against it, any plugin or anything you can advise? I get so much lately it’s driving me insane so any support is very much appreciated.
Excellent post. I was checking continuously this blog and I am impressed! Extremely helpful info specifically the last part 🙂 I care for such info a lot. I was seeking this certain info for a long time. Thank you and best of luck.
Awesome article.
We’re a group of volunteers and opening a new scheme in our community.
Your site provided us with valuable info to work on. You have done a formidable job and our entire community will be grateful to you.
Have you ever thought about adding a little bit more than just
your articles? I mean, what you say is valuable and everything.
Nevertheless imagine if you added some great photos or video clips to give your posts more,
“pop”! Your content is excellent but with pics and clips, this blog could
undeniably be one of the most beneficial in its niche.
Wonderful blog!
My brother recommended I may like this website.
He was once totally right. This put up actually made my
day. You can not imagine simply how so much time I had spent for this
information! Thanks!
Asking questions are genuinely good thing if you are not understanding something entirely, except this postpresents pleasant understanding even.
I have been absent for a while, but now I remember why I used to love this site. Thank you, I will try and check back more frequently. How frequently you update your web site?
I haven’t checked in here for a while as I thought it was getting boring, but the last few posts are great quality so I guess I’ll add you back to my everyday bloglist. You deserve it my friend 🙂
http://ededhardy.xprox.net/2012/01/the-degrading-and-decomposition-of-early-traditions-is-some-of-the-some-offices/
http://blog.splatterinc.com/?page_id=42
http://graphism.fr/pour-les-graphistes-vulgaires
Free game and app accounts are now live on the free account website. You can get instant access to all the game and application accounts you are looking for by going to our website. Free Accounts
http://iphone.dkszone.net/iphone-unlockers-stay-ios-4-3-1-update
It is now very easy to access premium accounts at no cost. Get instant access to the premium account you’re looking for by visiting the Free account website. You can access the most up-to-date accounts instantly by visiting Freeaccount.website now. Free Account
It is now very easy to access premium accounts at no cost. Get instant access to the premium account you’re looking for by visiting the Free account website. You can access the most up-to-date accounts instantly by visiting Freeaccount.website now. Free Account
Premium accounts are now completely free with freeaccount.website! Premium game and application accounts that are updated every day are shared on our website. Go to our website now and get login information for top-tier accounts at no cost. New Free Accounts
It’s actually very complex in this busy life to listen news
on Television, so I just use internet for that reason, and take the hottest news.
This piece of writing will help the internet visitors for
building up new weblog or even a blog from start to end.
I every time used to read post in news papers but now as I ama user of web thus from now I am using net for content,thanks to web.
http://blog.sixhonestservingmen.com/2010/04/06/hello-world/
It is not my first time to pay a visit this web site, i am browsing this website dailly and get
good data from here every day.
Oh my goodness! Amazing article dude! Thanks, However I am encountering troubleswith your RSS. I don’t know the reason why I cannot join it.Is there anyone else getting similar RSS problems? Anyonewho knows the answer can you kindly respond?Thanx!!
Hi, its good piece of writing regarding media print,
we all understand media is a wonderful source of facts.
Hello there! I know this is kind of off topic but I was wondering if you knew where I could find a captcha plugin for my comment form?I’m using the same blog platform as yours and I’m having trouble finding one?Thanks a lot!
http://politicalpiehole.com/empire-over-must-watch/
You don’t need to be a pro to score well in games! Get pro login information for many games with the free account website. Access premium accounts and passwords now for apps and web pages, not just games. New Free Account
You can reach all the entries you are looking for with freeaccount.website, which is one of the best platforms for current free accounts and passwords. Get direct logins and passwords for premium membership without the need for any additional apps. And you don’t have to pay anything for it! free account website
http://elcafedejoe.wordpress.com/2007/08/22/project-managers-a-la-moda/
You don’t need to be a pro to score well in games! Get pro login information for many games with the free account website. Access premium accounts and passwords now for apps and web pages, not just games. New Free Account
Looking for a premium account for games or apps? Then it’s time to check out the free account website. Hundreds of premium accounts and passwords updated daily in hundreds of different categories are now published on our website. Due to the high interest in the published accounts, we recommend that you browse our website before it runs out. Now go to our website for free accounts and don’t pay any premium apps.
You can reach all the entries you are looking for with freeaccount.website, which is one of the best platforms for current free accounts and passwords. Get direct logins and passwords for premium membership without the need for any additional apps. And you don’t have to pay anything for it! free account website
http://oczyszczanie-jelit.pl/chcesz-miec-ogrom-energii/
Have you ever thought about including a little bit more than just your articles?
I mean, what you say is valuable and all. But just imagine if you added some great graphics or video clips to give your posts more, “pop”!
Your content is excellent but with images and clips, this website could certainly be
one of the most beneficial in its field. Amazing blog!
Informative article, exactly what I needed.