cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TanguyT
Level: Powered On

How to perform an Associate request in PCF using Xrm.WebApi

Hi,

This is maybe not the most appropriate place to ask this question but I am fighting with this since weeks and there is absolutely no documentation anywhere on how to perform an association for a NN relationship using Xrm.WebApi.

 

As I need this for a PCF component, I'm asking here.

 

Can anyone provide a sample code on how to do this? The current code I have just ends with an unspecified error

 

var associateRequest = new class {
	target = {
		id: theRecordId,
		entityType: currentEntity
	};
	relatedEntities = [
	  {
		id: thisCtrl.parentRecordId,
	  entityType: "account"
	  }
	];
	relationship = "new_tag_account";
	getMetadata(): any {
	  return {
		boundParameter: undefined,
		parameterTypes: {
			"target":{
				"typeName": "mscrm.new_tag",
				"structuralProperty" : 5
			},
			"relatedEntities":{
				"typeName": "mscrm.account",
				"structuralProperty" : 4
			},
			"relationship":{
				"typeName": "Edm.String",
				"structuralProperty" : 1
			}
		},
		operationType: 2,
		operationName: "Associate"
	  };
	}
  }();

  // @ts-ignore
  thisCtrl._context.webAPI.execute(associateRequest)
  .then(
	 // @ts-ignore
	 function(result){
		  debugger;
	  },
	 // @ts-ignore
	 function(error){
		  debugger;
	  }
  );
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
TanguyT
Level: Powered On

Re: How to perform an Associate request in PCF using Xrm.WebApi

Ok, found it after days!!

 

the casing of the relationship name is important. With the correct casing, it worked

1 REPLY 1
Highlighted
TanguyT
Level: Powered On

Re: How to perform an Associate request in PCF using Xrm.WebApi

Ok, found it after days!!

 

the casing of the relationship name is important. With the correct casing, it worked