Setting up the GET URL

In step 3 of our custom JavaScript extension, we constructed the requestUrl parameter as follows:

Xrm.Page.context.getClientUrl() + 
"/api/data/v8.2/tasks?$filter=_regardingobjectid_value eq " + contactId + " and _ownerid_value eq " + currentUserId + " and statecode eq 0"

The getClientUrl() function returns the base URL of your Dynamics 365 instance. We then appended /api/data/v8.2, which is the address of the Web API endpoint, as defined under Settings | Customizations | Developer Resources | Instance Web API:

The URL construction will be different when running your query using an on-premise Dynamics 365 instance. It is highly recommended to refactor the URL construct in its own method.

Notice how currentUserId and contactId are extracted as variables to better understand the flow and for debugging purposes.

The URL looks for the task activity and uses the $filter keyword to only retrieve records related to the current record, owned by the current user with a statecode of 0 (Open).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.102.225