Tuesday, August 2, 2016

OData value get or set in CRM CRUD operation

OData Update: 

var objEntity =new Object();
Lookup:
 objEntity.RegardingObjectId =
    {
        Id: entityId,
        LogicalName: "incident",
        Name: subject
    };
Currency:
var objTotalValue = parseFloat(TotalValue);
 objEntity.QuoteTotalAmount =
    {
        Value: objTotalValue.toString()
    };
OptionSet:

var objTotalValue = 3;//OptionSet value not name
 objEntity.CustomerTypeCode=
    {
        Value: objTotalValue
    };
DateTime:
var dtDateTime= Xrm.Page.getAttribute('kti_datecheck').getValue();
//kti_datecheckvalue is a datetime control

 objEntity.kti_DateCheck=dtDateTime;
    
TwoOptions:

//kti_bIsAccountAddress is a twoOption date type control 
objEntity.kti_bIsAccountAddress=true;//value=false or true
OData Read:

Lookup:
var dGuid=Xrm.Page.data.entity.getId();
//Filter customer record in the contact 
var strFilter=$filter=ParentCustomerId/Id eq guid'"+dGuid+"'";
Currency:
//Credit limit is currency data type control 
var strFilter=$filter=CreditLimit/Value eq 1000;
DateTime:
var dtDateTime= Xrm.Page.getAttribute('kti_datecheck').getValue();
//kti_datecheckvalue is a datetime control

var strFilter=$filter=kti_DateCheck eq datetime'"+dtDateTime.toJSON()+"'";

//because ODate value filter supports universal format 2016-08-02T19:05:37Z
    
Option Set:
//Family status code is optionset data type control(value mention in the field) 
var strFilter=$filter=FamilyStatusCode/Value eq 3;
Two Option:


//Credit hold is two option data type control(value either true or false) 
var strFilter=$filter=CreditOnHold eq true;
Filter Guid:

//Credit hold is two option data type control(value either true or false) 
var strFilter=$filter=accountId  eq guid'37cd7ab5-a9ee-e611-80e8-3863bb34de80';

Filter Multiple Guid:

//Credit hold is two option data type control(value either true or false) 
var strFilter=$filter=accountId eq guid'37cd7ab5-a9ee-e611-80e8-3863bb34de80' or accountId eq guid'19b02e31-b4ef-e611-80e8-3863bb34de80' ;

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.