cancel
Showing results for 
Search instead for 
Did you mean: 

Checking if object is locked or not in SAP C4C SDK

Gayatri_Bagde
Active Participant
1,400

Hello Experts,

We have a scenario where we are updating data in Ticket Object from Activity using ABSL. But if the user is editing the ticket, then update to such ticket fails. We need to check if the ticket is being locked by any other user and if yes we will be showing an error message in activity from SDK. But I was not find any such method. By any chance, can we check if the object is being locked by user using ABSL?

Thanks in Advance,

Gayatri

View Entire Topic
itaKraus
Explorer
0 Kudos
hi 
 
i try to use the code you show above in a by design system 
 
please explain me 
 
some information aboute this line 
 
if (item.MessageSeverityText == "E" && item.MessageID.content == "AP_ESI_COMMON/101") {
 
 
because when i try out this code on a salesOrder locked object 
i never get this 
item.MessageID.content == "AP_ESI_COMMON/101" 
 
 
i see a message 
like this :
 
""
is it also for check if object is locked 
 
 
i see a problem 
after i get one object that locked 
it looks like all other object are locked also 
 
 
can you help me ?
 
 
 
below is my code 
 
 
var currentDate = Context.GetCurrentGlobalDateTime();
var currentDate1 = currentDate.ConvertToLocalNormalisedDateTime();
var SalesOrders = SalesOrder.QueryByElements;
var SalesOrderDate_SelParams = SalesOrders.CreateSelectionParams();
SalesOrderDate_SelParams.Add(SalesOrders.Status.ItemListCustomerOrderLifeCycleStatusCode, "I", "EQ", "1");
SalesOrderDate_SelParams.Add(SalesOrders.Status.ItemListCustomerOrderLifeCycleStatusCode, "I", "EQ", "2");
 
var SalesOrderData_Results = SalesOrders.Execute(SalesOrderDate_SelParams);
var ValidSalesOrderList : collectionof SalesOrder;
 
 
foreach (var SO in SalesOrderData_Results)
{
 
var uuid;
uuid = Library::UUID.ParseFromString(SO.UUID.content.ToString());// Opp ID 12450
var messages;
var lock;
 
lock = BOAction.CheckLock("SalesOrder", "http://sap.com/xi/AP/CRM/Global", "Root", uuid);
messages = lock.MessageTypeItem;
var validationFailed : Common:Indicator=false;
var a;
if (!lock.IsInitial() && messages.Count() > 0)
{
foreach (var message in messages)
{
// if(message.MessageSeverityText == "E" && message.MessageID.content.ReplaceRegex("[[:space:]]","") == "AP_ESI_COMMON/101")
if (message.MessageSeverityText == "E" && message.MessageID.content == "CL_CDA_DOCHD/000")
{
validationFailed = true;
break;
 
}
}
lock.Clear();
messages.Clear();
}
if (!validationFailed)
{
ValidSalesOrderList.Add(SO);
}
}
 
SalesOrderData_Results = ValidSalesOrderList;