Progress will discontinue Telerik Platform on May 10th, 2018. Learn more

How to Determine the Id of the Requested Data Item in Business Logic

Environment

Service Business Logic
Feature Cloud Code for Data

Applicable only to Cloud Code for Data.

Description

Often you may need to determine when data is accessed by item Id (and respectively the Id of the requested item). This may be helpful in cases when you would like to apply different business logic for data operations per Id and operations that are accessing or filtering all data items. For example, you may deny Delete requests that are not per Id. This check is applicable to Read, Update and Delete requests and their respective events in the Cloud Code for Data.

Solution

You can get the Id of the item from the request parameters but only if the request is made by Id as opposed to requests by filter (or to all items).

Example:

if (request.itemId) {
    // data is accessed per item Id
    // access the item Id 
    var requestedItemId = request.itemId;
} else {
    // the request is accessing all items or supplying a filter
}

See Also

Start a free trial Request a demo
Contact us: +1-888-365-2779
sales@telerik.com
Copyright © 2016-2017, Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.