Change channel based on selected user in an onchange Workflow script ?

SUGGESTED

Hi all,

I've read as much as possible in the forum and find it strange that no one ever asked for that exactly...

During Case creation, which runs under an enabled new Case Workflow rule, I want that the Channel field is dynamically changed when the user changes the assigned user.

I supposed basically that I would solve this easily with :

1) a Create Script that sets the case_assigneduserid "Defaultvalue=CurrentUser.user_userid;"

2)an OnChange Script on the case_assigneduserid to change the case_channelid, but then I find it impossible to do that easily as I am here stuck at a client side level.

var AssignedUserID = crm.fields("case_assigneduserid").value(); //this is quite easy to retrieve the assigned user id.

But what about finding the Channel Id of this AssignedUserId ?

How can I do that within the scope of the new Case Workflow rule ?

Any help would be appreciated...

Parents
  • 0

    If you are still struggling with this, then you could just hide the Team field in the 'New Case' Primary Rule and add an 'Execute SQL Statement' to be fired at the end. 

    UPDATE cases SET case_channelid = (SELECT user_primarychannelid from users WHERE user_userid = #case_assigneduserid#) WHERE case_caseid = #case_caseid#

    You can add the same action on the 'Re-assign' rule.

Reply
  • 0

    If you are still struggling with this, then you could just hide the Team field in the 'New Case' Primary Rule and add an 'Execute SQL Statement' to be fired at the end. 

    UPDATE cases SET case_channelid = (SELECT user_primarychannelid from users WHERE user_userid = #case_assigneduserid#) WHERE case_caseid = #case_caseid#

    You can add the same action on the 'Re-assign' rule.

Children
  • 0 in reply to Sean from Spire

    You're right, and that was m first idea, but this approach does not let the current user to select another team than the user assigned default one.

    By the way I'm going to ask my client if it can be ok for them.

  • 0 in reply to PPI-VDM
    SUGGESTED

    You could then do it as a SQL trigger on Cases and compare 'Inserted' to 'Deleted' thus if the Channelid is the same in both then you can overrule it with the primary team of the assigned user, if they're different then you just keep with the value being entered via the Insert (just need something else in there to stop a general update to Cases triggering a change to Channelid, some flag field that is written to if driven by the workflow or something)