Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3668

How to delete Records from Custom BO using MDR job

$
0
0

Hi.

 

We have created a MDR job that calls the delete action defined on custom BO.

 

mdr.png

There is Query object created on Custom BO automatically.

 

Query.png

 

When the Job runs and executes the Action : Delete should get  triggered but none of the data from custom BO where Backlog date is more than 31 days old gets deleted. Is there something wrong with code.

 

import ABSL;

 

/** Querying the OrderBacklog BO **/

var query = ZBO_OrderBacklog.QueryByElements;

 

/* Creating selection parameters **/

var selectionParams = query.CreateSelectionParams();

 

/** Fetching current date **/

var currentDate = Context.GetCurrentSystemDate();

 

/** Setting the threshold date as 31 days before the current date **/

var thresholdDate = currentDate.SubtractDuration(Duration.ParseFromString("P31D"));

 

/** Querying the BO on date less than the threshold date **/

selectionParams.Add(query.OrderBacklogDate, "I", "LT", thresholdDate);

 

/** Executing the query **/

var resultData = query.Execute(selectionParams);

 

/**  Deleting the records **/

foreach (var BO in resultData)

{

    BO.Delete();

}


Viewing all articles
Browse latest Browse all 3668

Trending Articles