Update Accountmanager based on Territory in Onchange

This question is not answered

I need to update accountmanager field whenever user selects the territory.Wrote below code but facing an error

var Terr=comp_secterr.value;
var actmaQuery="select user_userid from Territories Join Users on Terr_ParentID=User_PrimaryTerritory where Terr_TerritoryID="+Terr;
var Query = CRM.CreateQueryObj(actmanQuery);

Im new to sage CRM kindly let me know how to proceed.TIA

All Replies
  • on which event are you writing this code ?


    Kannan Srinivasan

  • on Territory field change .In onchange script section

  • Divya

    The code you have written looks like serversider code.  It is using objects that can only be used by Create, Validate and Table Level Scripts as this is code that is executed within the server.  The onChange event can only execute client side code, script that is executed in the browser.

    To fetch data from the database the Client Side API has AJAX capabilities.  See:  community.sagecrm.com/.../sage-crm-7-2-creating-ajax-calls-using-the-client-side-api.aspx