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.

Give the action a name and select “JavaScript” as the action type.

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.

Select the target class on which you want to run the sweep and select our previously created custom sweep action.

Finish the creation wizard an activate you sweep job.

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!

50 thoughts on “IBM FileNet – Update property values with a custom sweep action in bulk processing

  1. 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

  2. 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!

  3. 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?

  4. 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!

  5. Hi, of course this paragraph is in fact nice and I have learned lot of things from it on the
    topic of blogging. thanks.

  6. 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?

  7. 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.

  8. 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.

  9. 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!

  10. 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!

  11. 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?

  12. 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 🙂

  13. 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

  14. 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

  15. 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

  16. 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.

  17. 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.

  18. 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.

  19. 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!!

  20. 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!

  21. 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

  22. 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.

  23. 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

  24. 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!

Comments are closed.