xrmquery.update operation will be used to update the CRM ID binding to null

I am encountering an issue with using XrmQuery to update an id-binding field with a value of "null".

Below is the code snippet that I'm working with:

XrmQuery.update(x => x.contacts,
                recordId,
                {
                    address2_line1: null,
                    address2_postalcode: null,
                    address2_city: null,
                    cgk_origindate: null,
                    cgk_countrypostaladdressid_bind$cgk_countries: null,
                    cgk_originaddress: null
                }).execute(id => {
                });

The issue arises specifically when trying to set

cgk_countrypostaladdressid_bind$cgk_countries
to null.

Interestingly, removing this line results in the update functioning correctly. Is there a workaround or best practice for setting an id-binding field to "null" using XrmQuery?

Answer №1

If you're looking to clear lookup fields through an update-request made via the Web API, that won't work. You'll actually need to utilize a disassociate request instead. Unfortunately, at this time, the XrmQuery library does not have built-in support for associate/disassociate requests (XrmQuery documentation).

While we work on adding this functionality directly into XrmQuery (refer to issue 31), you can manually compose the request like so: As outlined in the MSDN documentation, you will need to use an HTTP DELETE request in a specific format. For nullifying lookups (referred to as single-valued navigation properties), you can set their value to null in the following manner:

XrmQuery.sendRequest("DELETE",
  "contacts(" + recordId + ")/cgk_countrypostaladdressid/$ref",
  null,
  () => { alert("success"); },
  () => { alert("error"); }
);

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for transferring information between different components through a collaborative service

Attempting to send data using a subject to another component for the purpose of earning, but experiencing difficulty retrieving the data. Below is the provided code snippet: app.component.ts import { Component } from '@angular/core'; import { s ...

find all the possible combinations of elements from multiple arrays

I have a set of N arrays that contain objects with the same keys. arr[ {values:val1,names:someName},   {values:val2,names:otherName}, ] arr2[   {values:valx,names:someNamex}, {values:valy,names:otherNamey}, ] My goal is to combine all possible c ...

Enabling logging for the Mapnik SQL query while generating the map

Currently, I am utilizing the npm package known as Mapnik in conjunction with PostGIS. My goal is to include logging functionality that captures the SQL query executed by Mapnik, along with the value of the bbox parameter, when executing the render() funct ...

Deploying Angular to a shared drive can be done in a

My angular.json file contains the following line: "outputPath": "Y:\Sites\MySite", After running ng build, I encountered the error message: An unhandled exception occurred: ENOENT: no such file or directory, mkdir 'D:& ...

Error: Unable to dispatch a Redux-thunk action with additional arguments in React

Currently, I am attempting to work with TypeScript alongside Redux-Thunk and Redux. My goal is to pass an object to any action (I am utilizing dependency injection and need to pass either an object service or a string). However, I encountered the followin ...

show additional worth on the console

Just starting out with JavaScript. Trying to display additional values in the console. Uncertain about how to access add-ons. Can anyone help me troubleshoot? Here is my code snippet below: https://jsfiddle.net/6f8upe80/ private sports: any = { ...

Material Angular table fails to sort columns with object values

Currently, I am in the process of developing a web application using Angular Material. One of the challenges I have encountered is displaying a table with sorting functionality. While sorting works perfectly fine on all columns except one specific column. ...

Encountering a Problem with Angular 2 RC HTTP_PROVIDERS

I recently upgraded my Angular 2 application to the RC version. Everything was working smoothly until I included HTTP_PROVIDER and created a service.ts file. However, now I am encountering an error: (index):14 Error: SyntaxError: Unexpected token <( ...

Can we confidently disregard React's caution regarding using the useState hook conditionally if only the parameter changes based on a condition?

In my React app, I am working on creating a calendar date selection function component to assign days to schedules. My goal is to pre-populate the calendar with existing data so users can modify it as needed. Here is what I have implemented so far: const ...

Incorporating Close, Minimize, and Maximize functionalities into a React-powered Electron Application

Struggling with implementing minimize, maximize, and close functionality for a custom title bar in an electron app using React Typescript for the UI. The issue lies within the React component WindowControlButton.tsx, as it should trigger actions to manipu ...

Shifting Angular Component Declarations to a New Location

Here's a question that might sound silly: In my Angular project, I am looking to reorganize my component declarations by moving them from angular.module.ts to modules/modules.modules.ts. The goal is to structure my src/app directory as follows: src ...

How can I eliminate the white bar elements from my dropdown menu? Also, seeking guidance on replacing an empty <div> tag in a boolean query

Can anyone help me understand the strange white border around my dropdown menu and guide me on how to remove it? I am currently using DropdownButton from react bootstrap. I have attempted to adjust the CSS with no success. Here is the code I tried: .Navig ...

How can one define a getter within an interface?

One of my classes is structured like this (only showing a portion here): export class LinkedListNode<t> extends windward.WrObject implements ILinkedListNode<t> { public get next(): LinkedListNode<t> { return this._next === thi ...

Executing service calls in a for loop in Angular 2 using the Http module

Encountered a challenge with Angular 2 HTTP service call within a for loop. The for loop executes quickly compared to the slow result returned by the service call. this.projectService.addProjectServices(pid, rid, vname, field_name, ser_name).subscribe( ...

TypeScript failing to infer a particular data type

When writing this code, TypeScript is throwing an error related to the map function: The property 'map' does not exist on type 'string | string[]'. It's puzzling because propertyValue in this scenario is clearly of type string[] ...

Encountered a specific issue with Angular 8's mat-autocomplete: "matAutocomplete" is not being recognized as a valid property of the "input" element

Currently, I am attempting to implement the example here from materialUI while working with Angular 8. The mat-chip-list functions properly without the mat-autocomplete feature, but I require it for my project. Below is a snippet of my code: <mat-chip ...

Issue arises when employing Higher Order Components in TypeScript

I encountered an issue with this code where it throws a "Cannot find name 'ComposedComponent'" error. I'm not sure why this is happening as I am just trying to create a simple Higher Order Component (HOC). import * as React from 'rea ...

The page has been updated following a refresh

I'm currently working on developing an Instagram-inspired platform using Angular 6, but I've run into a puzzling issue. When I refresh the page in my home component, everything reloads correctly and displays all my posts as expected. However, if ...

Angular 14.2.9: "Trouble with Form Data Binding - Seeking Assistance with Proper Data Population"

I'm currently using Angular version 14.2.9 and the component library I'm utilizing is: import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; While working on binding data to a form, I encountered an issue where the data wasn't d ...

How can you effectively handle ngxs state changes in your component to respond to loading or error events?

In the PostListComponent, I am iterating over posts retrieved from the server and displaying them using individual PostItemComponents. NGXS is being used for state management in this scenario. When initiating fetchPosts requests, I set the loading state pr ...