How to Make User Select Field Change Territory Field in Opportunity Creation?

  • Our CRM is set up that we have a user select field called oppo_salesperson. Our territories are divided into each salesperson. For example, Bob Sales is a user on CRM and there's a territory called Bob Sales's Territory. (His home territory is set to Bob Sales' Territory. This way he can only see the opportunities, Companies, and People that are in his territory.)

    On opportunity creation, I want the territory for the opportunity to automatically change to the person that is selected in the oppo_salesperson field. So when they type "Bob" in the use select field, the territory will automatically change to "Bob Sales's Territory."

    I see that the Territory is called oppo_secterr, so I'm thinking maybe some code in the oppo_salesperson OnChangeScript. Is this possible?

    Here's an algo I threw together.

    if(oppo_salesperson = 'BobSales'){
    oppo_secterr = 'Bob Sales's Territory';
    }else if(oppo_salesperson = 'RogerSales'){
    oppo_secterr = 'Roger Sales's Territory';

    Otherwise, change the oppo_secterr (Territory) field in the OnChangeScript so that the user select field oppo_salesperson fills out automatically? 

  • This is a similar question in this forum thread

    community.sagecrm.com/.../11359.aspx


  • I got the switch to work with this basic code:

    switch (this.value) {

    case 'Pete' :

    document.getElementById('oppo_secterr').value = '-385445868';

    break;

    }

    So in a text field, like oppo_note, when I type Pete it pops over which is great, but my oppo_salesperson is a user select field, and examining the code doesn't reveal what the values are for each user is. Where can I see a list of these?

    I figured out to type a name in, then click change, then look at the code, then look at the OPTION VALUE attached to the name. I've got toe repeat it for all the sales we have, which is time consuming (but it works).

    Also, is there a wildcard I could use for that code? In the oppo_note if "Pete" is typed it changes, but anything before or after and it doesn't register. Is there something similar to the "%" symbol that I could put in so anywhere in the text box it sees "Pete" it will change? (For future information.)