By Territory

Suppose you want to search records within specified territories. For this, we have created the custom action with name “Inogic.Maplytics.API.Territory” (ikl_InogicMaplyticsAPITerritory).

Custom action accepts the following parameters.

  • Territories: Specify the names of territories. E.g., “FL, NY”.

  • Entity: Specify the entity name. e.g., “Account"

  • ViewName: Specify the view name. e.g., “My active accounts”

When user passed the required parameters and executes this action then the action will return the collection of records.

To execute region action using the C#, use following code.

string requestName = "ikl_InogicMaplyticsAPITerritory";

                    //create request object
                    OrganizationRequest orgReq = new OrganizationRequest(requestName);

                    //for Territories
                    orgReq["Territories"] = "NY";                  

                    //Entity & view
                    orgReq["Entity"] = "account";
                    orgReq["ViewName"] = "My Active Accounts";

                    OrganizationResponse response = service.Execute(orgReq);

                    EntityCollection recordsCollection = (EntityCollection)response.Results["RecordsCollection"];

To execute the action using the javascript (web api) you can use following code.

//By territory
        var actionObj = {
            Territories: "NY",          
            Entity: "account",
            ViewName: "My Active Accounts",
        }

        // call this function to execute the action 
        execute(actionObj, "ikl_InogicMaplyticsAPITerritory()", function (data) {

            alert("Success: " + data);

        }, function (error) {
            debugger;
            alert("Error: " + error.message);
        });

Last updated