This discussion is archived
5 Replies Latest reply: Feb 20, 2008 10:42 PM by 807573 RSS

multiple deferred tasks

807573 Oracle ACE
Currently Being Moderated
Hi,

I want to add several deferred tasks to a user.
Each deferred task should invoke the same
workflow, but use different parameters (arguments).

The documentation suggests that this can be done:

"This method supports the ability to add multiple versions
of the same task definition to a user.
See the description of the taskDefinition argument for more information."

However, the description of the taskDefinition argument
does not offer any more information (that I can understand, at least).
Everytime I try to add another deferred task to the user,
the original deferred task gets overwritten.

Has anyone done this? If so how?

Thanks,

John I
  • 1. Re: multiple deferred tasks
    807573 Oracle ACE
    Currently Being Moderated
    Has anybody found a solution to this?? It's true the documentation does say it's supported but i just looked at the code for addDeferredTask and anytime it adds a new task it deletes any old tasks with that same name.....
  • 2. Re: multiple deferred tasks
    807573 Oracle ACE
    Currently Being Moderated
    This has been an issue since way back in the waveset 3.x days. For some reason IDM sets the name of the task to be the workflow. I have no idea why. The way we got around this was to rewrite the deferred task handler java class so that the ojbect i create has a name (which is any name i give it) and the workflow is simply an argument inside the object...for example name=deprovisionUser workflow=Disable User...then name=deprovisionUser and workflow=Delete User. When I saw that Sun had "fixed" this issue I re-read the documentation again and to me it seems that the same problem exists.

    Another way to do this (if you have to kick off the same workflow multiple times on a user) is to not use deferred tasks at all. Simply store a date and make it queriable. Either update that date each time you run the workflow to the next time you need to run the workflow, or use that date as a key to when the workflow needs to be executed (for example, notify a user in 15, 10, 5, 2,1 days before expiration). In this case you would not use the deferred task handler at all, but would rather build a custom workflow and query the date to find the users that you need to execute the workflow on. This is much easier to manage in the code as well. Then, simply schedule the task to run each night and you're money!.

    I hope this helps.

    Dana Reed
  • 3. Re: multiple deferred tasks
    807573 Oracle ACE
    Currently Being Moderated
    Thanks for the prompt response danareed...unfortunately we need those multiple deferred tasks so that any time select resources are disabled on the user we would schedule a deferred task for those select resources to be disabled....

    we ended up just checking out a persistent user object and using setProperty to set the 'tasks' property list....this allowed us to add multiple generic objects with the same name (the name of the task to be run) on the user obj
  • 4. Re: multiple deferred tasks
    807573 Oracle ACE
    Currently Being Moderated
    We had a similar situation and came up with the same solution. It's cumbersome, but works.

    Here's some sample code, in case anyone needs it --

    user = accountId of the user to receive the deferred tasks
    dateList = a list of dates for the task in question.
    taskName = the name of the task to be executed.
    <Activity id='4' name='Set Tasks'>
              <Variable name='dl'/>
              <Variable name='object'/>
              <Action id='0' name='Checkout User' application='com.waveset.session.WorkflowServices'>
                <Argument name='op' value='checkoutObject'/>
                <Argument name='type' value='User'/>
                <Argument name='name' value='$(user)'/>
              </Action>
              <Action id='1' name='Set Task Property'>
                <expression>
                <!-- FYI, the variable 'object' now contains the 
                       results of the checkoutObject call.  This sleight
                       of hand is in the Workflow documentation for
                       the checkoutObject Session Workflow Service.
                 -->      
                  <block>
                      <dolist name='dl'>
                          <ref>dateList</ref>
                           <cond>
                                <isnull>
                                    <invoke name='getProperty'>
                                        <ref>object</ref>
                                        <s>tasks</s>
                                    </invoke>
                                </isnull>
                                <invoke name='setProperty'>
                                    <ref>object</ref>
                                    <s>tasks</s>
                                    <list>
                                        <block >
                                            <defvar name='obj'>
                                                <new class='com.waveset.object.GenericObject'/>
                                            </defvar>
                                            <set>
                                                <ref>obj</ref>
                                                <s>name</s>
                                                <ref>taskName</ref>
                                            </set>
                                            <set>
                                                <ref>obj</ref>
                                                <s>date</s>
                                                <invoke name='parse'>
                                                    <new class='java.text.SimpleDateFormat'>
                                                        <s>MM/dd/yyyy</s>
                                                    </new>
                                                    <ref>dl</ref>
                                                </invoke>
                                            </set>
                                            <set>
                                                <ref>obj</ref>
                                                <s>description</s>
                                                <ref>dl</ref>
                                            </set>
                                            <ref>obj</ref>
                                        </block>
                                    </list>
                                </invoke>
                                <invoke name='setProperty'>
                                    <ref>object</ref>
                                    <s>tasks</s>
                                        <block >
                                            <appendAll>
                                                <invoke name='getProperty'>
                                                    <ref>object</ref>
                                                    <s>tasks</s>
                                                </invoke>
                                                <block>
                                                    <defvar name='obj'>
                                                        <new class='com.waveset.object.GenericObject'/>
                                                    </defvar>
                                                    <set>
                                                        <ref>obj</ref>
                                                        <s>name</s>
                                                        <ref>taskName</ref>
                                                    </set>
                                                    <set>
                                                        <ref>obj</ref>
                                                        <s>date</s>
                                                        <invoke name='parse'>
                                                            <new class='java.text.SimpleDateFormat'>
                                                                <s>MM/dd/yyyy</s>
                                                            </new>
                                                            <ref>dl</ref>
                                                        </invoke>
                                                    </set>
                                                    <set>
                                                        <ref>obj</ref>
                                                        <s>description</s>
                                                        <ref>dl</ref>
                                                    </set>
                                                    <ref>obj</ref>
                                                </block>
                                            </appendAll>
                                        </block>
                                </invoke>
                             </cond>
                      </dolist> 
                  </block>
                </expression>
              </Action>
              <Action id='2' name='Checkin the User Object' application='com.waveset.session.WorkflowServices'>
                <Argument name='op' value='checkinObject'/>
                <Argument name='object' value='$(object)'/>
              </Action>
            <Transition to='end'/>
          </Activity>
    Jason
  • 5. Re: multiple deferred tasks
    807573 Oracle ACE
    Currently Being Moderated
    It turns out there really is no need to call the addDeferredTask or removeDeferredTask workflow services as a separate call if you already have a checkoutView/checkinView. The deferred object are actually on the view under:
    user.accounts[Lighthouse].properties.tasks[someTaskName]

    So even though addDeferredTask will not let you add multiple deferred task for the same task, we can use the view instead since on the view this is just a list of generic objects (each object encapsulates which task to run as well as anyargument to be passed into the task),thereby allowing us to have multiple deferred tasks for the same tasks.

    So if u want to schedule the workflow someTaskName to run in a month but the user already has a task object for someTaskName you would just create a new generic object with a name of someTaskName (along with any of the other required attributes needed i.e. date, taskName, descriptions....)and just append it to this list and check in the view.