locked
Changing Team's BU and then assigning role - plugin issues RRS feed

  • Question

  • I am looking for a perfect solution for this:

    I have a plugin which moves a team from BU1 to BU2 (using SetParentTeamRequest) and then assigns a role R2 (which is associated with BU2). I get an exception that, team and role belong to different BU. I put a Thread.Sleep(100) between the two operations, and the plugin processed without any exception.

    Ok, so it takes some time to move to new BU and there should be some request using which I could check if the team has moved to new BU or not (just like we can check for privileges after assigning role to a team as it also takes some time). But I didn't find anything to check this. Checking for businessunitid in team is of no use as it gets updated right after the processing of SetParentTeamRequest, but then the plugin throws exception if processed with adding the sleep code. I tried to catch the exception and then wait and then try again. But once exception is thrown, no matter how much time I wait, it throws the same exception again on retry.

    Has anyone faced this? Anyone has a better approach for this? I just need to change the BU of team and then assign a role to it.

    I am on CRM2011-RU11.


    - Arvind

    Saturday, May 25, 2013 5:00 AM

Answers

  • Hi Arvind,

    That is rather frustrating - I feel your pain!!

    Perhaps, the only way would be to create a re-try loop that tries to add the role, and if it fails with your favourite message, it keep retrying until successful. You could put a max retry of 5 times.

    Whilst this approach wouldn't be a good idea if you are performing this operation lots of times, I'm guessing it's an occasional operation and so won't be a problem.

    hth


    Scott Durow
    Read my blog: www.develop1.net/public     Follow Me on Twitter
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Monday, May 27, 2013 11:37 AM
    Answerer
  • Hi Arvind,

    I would avoid creating unnecessary records - and use the exception catch retry technique.


    Scott Durow
    Read my blog: www.develop1.net/public     Follow Me on Twitter
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Wednesday, May 29, 2013 7:40 AM
    Answerer

All replies

  • Hi Arvind,

    Never noticed this and is good to know.

    You could poll the roles assigned to the team and once there are none because they are automatically then assign new roles.

    hth


    Scott Durow
    Read my blog: www.develop1.net/public     Follow Me on Twitter
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Saturday, May 25, 2013 8:33 AM
    Answerer
  • Hi Scott,

    Tried your suggestion, but it seems that even after all previous roles are removed automatically after moving to new BU, it still takes sometime for the team to get set.

    I put a loop to check if all roles have been removed, it runs just once. This means all previous roles are removed synchronously in the SetParentTeamRequest execution.

    I need to permanently fix my Thread.Sleep(100) temporary fix, which seems to be saving me till now!

    I hate this message now "The team belongs to a different business unit than the role."

    Any more ideas? :)


    - Arvind

    Monday, May 27, 2013 8:28 AM
  • Hi Arvind,

    That is rather frustrating - I feel your pain!!

    Perhaps, the only way would be to create a re-try loop that tries to add the role, and if it fails with your favourite message, it keep retrying until successful. You could put a max retry of 5 times.

    Whilst this approach wouldn't be a good idea if you are performing this operation lots of times, I'm guessing it's an occasional operation and so won't be a problem.

    hth


    Scott Durow
    Read my blog: www.develop1.net/public     Follow Me on Twitter
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Monday, May 27, 2013 11:37 AM
    Answerer
  • Hi Scott,

    Thanks for the suggestion. But I have already tried this and have put the info in my first post. I am afraid its not very neatly written :)

    Once the exception raised in assigning role, I keep on getting the same exception regardless of the wait time I put before retrying (I tried for a full minute and more!).

    Just experimented something: Moved the team to new BU -> Created a task with the team as owner -> checked task's owningbusinessunit.

    Below is my custom log:

    <I>BusinessUnit: 885d5bb4-c4ad-e211-807c-005056850171 found for team: 2f0a974e-b6c3-e211-9820-0800276f0262</I>
    ...
    <I>Assigning BU: 93f804a7-c4ad-e211-807c-005056850171 to team: 2f0a974e-b6c3-e211-9820-0800276f0262</I>
    <I>BU Id of new task is: 885d5bb4-c4ad-e211-807c-005056850171</I>
    <I>Team's BU Id: 93f804a7-c4ad-e211-807c-005056850171</I>

    I am now actually thinking of using this to perform the check. It really hurts to create a record(and subsequently delete it) just to check if team has moved to new BU or not. I am not sure if this has been taken care of in the recent roll-ups. The evn. is not in my hand and I am stuck with RU11 as of now.


    - Arvind

    Tuesday, May 28, 2013 2:40 PM
  • Hi Arvind,

    I would avoid creating unnecessary records - and use the exception catch retry technique.


    Scott Durow
    Read my blog: www.develop1.net/public     Follow Me on Twitter
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Wednesday, May 29, 2013 7:40 AM
    Answerer
  • Hi Scott,

    Haven't got any better solution for this and it seems that role assignment to team cannot be guranteed by checking 'RetrieveTeamPrivilegesRequest' anymore.

    I used the exception - catch retry for the issue using PreValidation plugin since it runs out of transaction and so allows to continue even after faultexception.

    Thanks for all the help. marking your post as answer as it seems there is no better answer, atleast for now.


    - Arvind

    Tuesday, June 18, 2013 11:37 AM