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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Map primary incident type from work order to work order product

(0) ShareShare
ReportReport
Posted on by 905

Hello everyone,

I would like to populate automatically the Work order incident (Lookup value) while creating a new work order product from the work order entity based on the primary incident type value.
Mapping.png

I have tried to configure the mapping between those two fields but I got the below error:
Screenshot-2022_2D00_02_2D00_19-150721.pngScreenshot-2022_2D00_02_2D00_19-150640.png

It seems that the mapping will not work and I would need to do it through JS onLoad of the Work order product form to set the Lookup value automatically for that field.

If so, could you please confirm if this is the right way of doing it and provide a sample code?

Any help is highly appreciated.

Thank you!

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at

    Hi EBMRay,

    Yes, you could use onLoad to do this. Please try this code:

    function onload(executionContext) { 
    	var formContext = executionContext.getFormContext();
    	var workorder = formContext.getAttribute("msdyn_workorder").getValue();
    	if(workorder != null && workorder.length > 0){
    		var workorderID = workorder[0].id.replace("{","").replace("}","");
    		Xrm.WebApi.retrieveMultipleRecords("msdyn_workorderincident", "?$filter=_msdyn_workorder_value eq "   workorderID).then(
    			function success(result){
    				if(result.entities != null && result.entities.length > 0){
    					var incident_type = new Array();
    					incident_type[0] = new Object();
    					incident_type[0].id = result.entities[0]["msdyn_workorderincidentid"];
    					incident_type[0].entityType = "msdyn_workorderincident";
    					incident_type[0].name = result.entities[0]["_msdyn_incidenttype_value@OData.Community.Display.V1.FormattedValue"];
    					formContext.getAttribute("msdyn_workorderincident").setValue(incident_type);
    				}
    			}, function fail(error){
    				console.log(error.message);
    			}
    		); 
    	}
    }
    

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 Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
11manish Profile Picture

11manish 91

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 78 Super User 2026 Season 1

#3
Martin Dráb Profile Picture

Martin Dráb 55 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans