Posts

Showing posts from October, 2017

State Status Code Update On ServiceActivity Entity

// JavaScript source code //var Id = Xrm.Page.data.entity.getId().replace("{","").replace("}",""); function changeStatus() {     debugger;         //Set the stage to send enquiry letter         XrmSvcToolkit.setState({             id: Xrm.Page.data.entity.getId().replace("{", "").replace("}", ""),             entityName: "serviceappointment",             stateCode: 0,             statusCode: 1, //New             async: false,         });     //Save and Reload form         updateService();               Xrm.Page.data.refresh(true); } function updateService() {     debugger;     XrmSvcToolkit.updateRecord({         entityName: "ServiceAppointment",...

Retrieve All Records using fetch Xml in WebApi

///////////////////////AllEntityMetdata/////////////////////////////////////// var url = req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/EntityDefinitions", false); /////////////////////////////////FetchRequest///////////////////////////// var fetchxmlcode="<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+   "<entity name='account'>"+     "<attribute name='name' />"+     "<attribute name='primarycontactid' />"+     "<attribute name='telephone1' />"+     "<attribute name='accountid' />"+     "<order attribute='name' descending='false' />"+     "<filter type='and'>"+       "<condition attribute='createdon' operator='last-x-hours' value='1' />...

Meta Data Using WebApiRequest

////////////////Query Entity Metadata along with all attributes///////////// var url = req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/EntityDefinitions(LogicalName='contact')/Attributes", false); /////////////////Entity Object Type code///////////////////////  req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.0/EntityDefinitions?$filter=LogicalName eq '" + entityLogicalName + "'&$select=ObjectTypeCode", false); ////////////////////////////////////Querying single Field Metadata///////////////////// var url = req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/EntityDefinitions(LogicalName='contact')/Attributes(LogicalName='firstname')", false); /////////////////Querying Relationships/////////////////// var url = req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/RelationshipDefinitions(SchemaName...

Curd Operations Using XrmSvcToolkit

/////////////CURD Operation Using XrmSvcToolkit//////////////////////////// var entity = {}; entity.new_Currency = { Value: parseFloat(123).toFixed(4) }; entity.new_Customer = {     Id: "123456789",     LogicalName: "account" }; entity.new_DataandTime = new Date("10/18/2017").toLocaleString(); entity.new_DecimalNumber = parseFloat(12323).toFixed(2); entity.new_FloatPointNumber = parseFloat(2321.44).toFixed(2); entity.new_Lookup = {     Id: "1234567",     LogicalName: "account" }; entity.new_MultiLineTextBox = "test"; entity.new_OptionSet = { Value: 1 }; entity.new_SIngleLineTExt = "testing"; entity.new_TwoOption = false; entity.new_WholeNumber = 123; XrmSvcToolkit.createRecord({     entityName: "Account",     entity: entity,     async: false,     successCallback: function (result) {         var newEntityId = result.AccountId;     },     err...

Curd Operations Using XrmServiceToolkit

var entity = {}; entity.new_Currency = { Value: parseFloat(123).toFixed(4) }; entity.new_Customer = {     Id: "21323424434",     LogicalName: "account" }; entity.new_DataandTime = new Date("10/18/2017").toLocaleString(); entity.new_DecimalNumber = parseFloat(2132144).toFixed(2); entity.new_FloatPointNumber = parseFloat(232.432).toFixed(2); entity.new_Lookup = {     Id: "23234324",     LogicalName: "account" }; entity.new_MultiLineTextBox = "test"; entity.new_OptionSet = { Value: 3 }; entity.new_SIngleLineTExt = "tesxt"; entity.new_TwoOption = true; entity.new_WholeNumber = 21342; XrmServiceToolkit.Rest.Create(     entity,     "AccountSet",     function (result) {         var newEntityId = result.AccountId;     },     function (error) {         alert(error.message);     },     false ); var entity = {}; entit...

Curd Operations Using Jquery

////////create//////////// var entity = {}; entity.new_Currency = { Value: parseFloat(213).toFixed(4) }; entity.new_Customer = {     Id: "21321434",     LogicalName: "account" }; entity.new_DataandTime = new Date("10/13/2017").toLocaleString(); entity.new_DecimalNumber = parseFloat(2321).toFixed(2); entity.new_FloatPointNumber = parseFloat(221.342).toFixed(2); entity.new_Lookup = {     Id: "4343535255435454",     LogicalName: "account" }; entity.new_MultiLineTextBox = "fdsffdgf"; entity.new_OptionSet = { Value: 1 }; entity.new_SIngleLineTExt = "gdfgfdgdf"; entity.new_TwoOption = true; entity.new_WholeNumber = 232434; $.ajax({     type: "POST",     contentType: "application/json; charset=utf-8",     datatype: "json",     url: Xrm.Page.context.getClientUrl() + "/XRMServices/2011/OrganizationData.svc/AccountSet",     data: JSON.stringify(entity),     be...

created Record data Using Web Api Request

var entity = {}; entity.new_currency = Number(parseFloat(13666).toFixed(4)); entity["new_customer_account@odata.bind"] = "/accounts(F62765A4-941A-E711-8117-C4346BDC5E51)"; entity.new_datetime = new Date("04/12/2017").toISOString(); entity.new_decimal = parseFloat(22.223).toFixed(2); entity.new_floatpoint = parseFloat(2.3215).toFixed(2); entity["new_lookuponaccountfromcontact@odata.bind"] = "/contacts(D9058775-01F0-E611-812C-5065F38C8781)"; entity.new_optionset = 1; entity.new_twooptionset = false; entity.new_wholenumber = null; entity.accountnumber = ""; var req = new XMLHttpRequest(); req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/accounts", false); req.setRequestHeader("OData-MaxVersion", "4.0"); req.setRequestHeader("OData-Version", "4.0"); req.setRequestHeader("Accept", "application/json"); req.setRequest...