Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum
Answered

I need to fetch related records and Create new records with same details - D365 Field service

Posted on by 20

Scenario-

I have work orders with asset lookup. Asset has its own Checklist(Similar to service tasks). ' Asset check list is one entity and work order checklist is another entity.

when work order is created i need to fetch check list records for asset and create ' Work order checklists'  from asset checklists. 

I am not technical person, is there anyway to achieve this?

if no other option then kindly suggest how to write code .

  • Sayali Profile Picture
    Sayali 20 on at
    RE: I need to fetch related records and Create new records with same details - D365 Field service

    Hi Leah

    work order is getting created from agreement and asset field getting mapped on create itself. i tried with filter array as well. without filter work order checklist records are created. so issue is only at filter. i removed and added filter again and rechecked if i am choosing correct values.

    is it something with filter with lookup field ?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: I need to fetch related records and Create new records with same details - D365 Field service

    Hi Sayali,

    What I mean is that the Primary incident customer asset must be filled when work order created.If you don't fill it or fill it after creating order, the flow will appear following error.

    pastedimage1619429869952v3.png  

    pastedimage1619430205147v5.png pastedimage1619430058337v4.png

    From the screenshot, you can check that Primary incident customer asset field value is null.

    And make sure that you have selected correct value in the flow.

    pastedimage1619429659157v2.png

    Regards,

    Leah Ju

  • Sayali Profile Picture
    Sayali 20 on at
    RE: I need to fetch related records and Create new records with same details - D365 Field service

    Hi Leah,

    Primary incident customer asset is not null, work order has value in Primary incident customer asset lookup .

    can we try with filter array?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: I need to fetch related records and Create new records with same details - D365 Field service

    Hi Sayali,

    It's a matter of test data, you can check ‘Primary Incident Customer Asset’ field of the work order, you must make it is not null.

    pastedimage1619425002049v1.png

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

  • Sayali Profile Picture
    Sayali 20 on at
    RE: I need to fetch related records and Create new records with same details - D365 Field service

    Hi Leah, Thanks for the reply, I tried as you suggested, and used _cfm_asset_value as given in output query.

    pastedimage1619421968277v1.png

    but now i am facing another issue:

    pastedimage1619422016192v2.png

    Error: A binary operator with incompatible types was detected. Found operand types 'Edm.Guid' and 'Edm.String' for operator kind 'Equal'.

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: I need to fetch related records and Create new records with same details - D365 Field service

    Hi Sayali,

    The best way I found how to make the Filters work on Dynamics is to:

    1.Run the Flow with List Dynamics action without the filter.

    pastedimage1619419248065v1.png

    2.Check the results of the Flow run, and look for the value you wish to be filtering on.

    pastedimage1619419384300v2.png

    3.Copy the field name without id and use that as the filter.

    pastedimage1619419496027v3.png

    Note that Lookup Fields may be the reason your filters are not working.

    For example in my screen captures the field name of the filter I am trying to use is {new_assetid} but because it is a lookup when I did the List all records I found that the field I need to filter on is {_new_assetid_value}.

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

  • Sayali Profile Picture
    Sayali 20 on at
    RE: I need to fetch related records and Create new records with same details - D365 Field service

    This is the error:

    pastedimage1619338647258v1.png

  • Sayali Profile Picture
    Sayali 20 on at
    RE: I need to fetch related records and Create new records with same details - D365 Field service

    HI Leah,

    thank you for your reply. I followed all steps, but its failing at below step. Schema name of asset lookup in Asset Checklist entity is cfm_asset.

    pastedimage1619334869827v1.png

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: I need to fetch related records and Create new records with same details - D365 Field service

    Hi Partner,

    Has the problem been solved? Any updates?

    Please click Yes under "Did this answer your question?" to close this thread.

    pastedimage1619165734165v1.png 

    Thanks. 

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: I need to fetch related records and Create new records with same details - D365 Field service

    Hi Sayali,

    From your description, I get following information:

    Asset and Work order is 1:N relationship

    Asset and Asset checklist is 1:N relationship

    Work order and Work order checklist is 1:N relationship

    Asset checklist and Work order checklist entities are custom entities you created?

    You want to create Work order checklist with value from Asset checklist, right?

    If so, maybe you can firstly use power automate to create an automated flow to achieve it, which is no-code and easier that code.

    Go Power Automate(https://us.flow.microsoft.com/en-us/ )

    pastedimage1618993254863v2.png

    2.Trigger

    pastedimage1618997633021v3.png

    3.List rows action--Fetch Asset checklist for the asset that related to the new work order.

    pastedimage1618997765403v5.png

    Note:new_assetid is logic name of the lookup field.

    pastedimage1618998259452v9.png

    4.Add a new row action--create work order checklist with value from asset checklist.

    pastedimage1618997860913v6.png

    5.Test.

    One asset named 'asset1' has three asset checklist value.

    pastedimage1618998141372v8.png

    when i create new workorder and select asset1, save and refresh current form, work order checklist records can created automatically.

    pastedimage1618998100249v7.png

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,584 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,864 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans