web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to perform an Asso...
Power Apps
Answered

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

(0) ShareShare
ReportReport
Posted on by 113 Most Valuable Professional

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;
	 }
 );
I have the same question (0)
  • Verified answer
    Tanguy TOUZARD Profile Picture
    113 Most Valuable Professional on at

    Ok, found it after days!!

     

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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 547

#2
WarrenBelz Profile Picture

WarrenBelz 444 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 322

Last 30 days Overall leaderboard