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 :
Service | Customer Service, Contact Center, Fie...
Answered

Access subgrid for WO service tasks with JS in Mobile App

(0) ShareShare
ReportReport
Posted on by 2,911

I need to check that all WorkOrder Service Tasks are complete prior to a Booking be closed in the Field Service Mobile App

I already get one attribute from the Service Tab and set a field required based on some logic which works well

var faultcategory = formContext.ui.tabs.get(3).sections.get(0).controls.get(0).getAttribute("eye_faultcategory").getValue();

however I can't get the gridContext as below it always returns null

var formContext = executionContext.getFormContext();
var gridContext = formContext.getControl("workorderservicetasksgrid");

This is OnSave as well so I don't believe it's due to not being loaded.

Also confirming this is the Bookable Resource Booking form that integrates the WorkOrder form as well.

Any better ideas I was planning to get rows and check all completed.

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

    Hi antc,

    You can refer the following link:

    Get row data from the Sub-Grids in Dynamics 365 - CRM Crate 

  • antc Profile Picture
    2,911 on at

    Hi Leah

    Thanks for the link.

    My problem is I am getting null returned. I have tried to find it using the debugger without success. I suspect this code would work on a normal form however the nature of the bookable resource Booking form is causing me issues.

    Regards

    Antony

  • antc Profile Picture
    2,911 on at

    Asked this question in Field Service Forum however not really FS specific

    I need to check that all WorkOrder Service Tasks are complete prior to a Booking be closed in the Field Service Mobile App

    I already get one attribute from the Service Tab and set a field required based on some logic which works well

    var faultcategory = formContext.ui.tabs.get('fstab_service').sections.get('fstab_service_section_general').controls.get('msdyn_workorder2').getAttribute("eye_faultcategory").getValue();

    however I can't get the gridContext as below it always returns null

    var formContext = executionContext.getFormContext();
    var gridContext = formContext.getControl("workorderservicetasksgrid");

    This is OnSave as well so I don't believe it's null due to not being loaded.

    Also confirming this is the Bookable Resource Booking form that integrates the WorkOrder form as well.

    Any better ideas I was planning to get rows and check all completed.

  • Suggested answer
    Gabriel Dias Junckes Profile Picture
    2,428 on at

    Hi Antony.

    The mobile phone uses a Custom Component so you may not have access to all the attributes.

    It will also have more chances to break if the subgrid or view gets updated.

    How about you do a retrieve to return those records on the saving button? You could also check if there is another open booking (e.g. the technician scheduled another follow-up).

  • antc Profile Picture
    2,911 on at

    Hi Gabriel

    The App works in offline mode so don't know if I can do a retrieve.

    As mentioned I can access a column on the same form tab and it's MS OOB subgrid so should be supported.

  • Verified answer
    Gabriel Dias Junckes Profile Picture
    2,428 on at

    Hi Antony.

    You can retrieve the records when offline, assuming all the records you need are synchronized.

    docs.microsoft.com/.../offline

    Regarding the tab access, I am unsure about getting the object.

  • antc Profile Picture
    2,911 on at

    Thanks Gabriel I had forgotten that retrieve was supported will mark as answered and will also update as MS support are having a look at the grid access as well if we can work out how to access.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 54 Most Valuable Professional

#2
11manish Profile Picture

11manish 21

#3
AT-28040446-0 Profile Picture

AT-28040446-0 13

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans