jasonscript jasonscript - 26 days ago 10
Javascript Question

Custom Tab in the Field Service Schedule Board

I found this blog: http://www.powerobjects.com/2016/08/01/advanced-customizations-for-the-custom-tab-in-the-field-service-schedule-board/#collapse2

In it the author describes using configuration to create a new tab in the Field Services

Schedule Board
by pointing it to a CRM web resource.

The blog includes the following javascript:

function updateBooking()
{
var entityRecordGuid = "10B8A40B-D499-E611-80E6-A45D36FC5A4C";

// GUID is hardcoded to make the sample code easier to understand.
// We can extend this customization to be able to extract the selected booking IDs
// from the SChedule Board's DOM, but that is out of scope for now

var bookableResourceBooking = new XrmServiceToolkit.Soap.BusinessEntity("bookableresourcebooking", entityRecordGuid);

bookableResourceBooking.attributes["cus_urgency"] = document.getElementById('UrgencyInput').value;
bookableResourceBooking.attributes["cus_notes"] = document.getElementById('NoteInput').value;

var updateResponse = XrmServiceToolkit.Soap.Update(bookableResourceBooking);

if (updateResponse == "") { // clear fields if synced to crm
document.getElementById('UrgencyInput').value = "";
document.getElementById('NoteInput').value = "";
} else {
alert('Data didn't sync to CRM');
}
}


The problem that I've got is that I'm not sure how to get the
entityRecordGuid
value dynamically.


  • There doesn't seem to be a way of configuring the web resource to
    have the selected Item as part of the querystring

  • There seem to be undocumented JavaScript libraries for Field
    Services; however, I can't access them from the web resource
    IFrame

    and of course, they're undocumented.



Has anyone else tried to do this? I'm using CRM Online

Answer

I ended up doing this by scraping the HTML directly rather than trying to use any of the API methods from Field One.

This wasn't really a satisfactory answer for me. It depends on the Unscheduled Orders board being in a certain order and since this is changeable by the end-user my solution is very fragile.

For anyone else looking, I did manage to find these API methods; however, I couldn't find any documentation for them so assume that they are unsupported. I also couldn't tie them together to achieve what I wanted

// get the id of the sub grid
F1SDK.SchedulerPage.UnscheduledOrdersGrid.id          
    // -> "UnscheduledGrid"

F1SDK.SchedulerPage.UnscheduledOrdersGrid.getItemId() 
    // -> "UnscheduledGrid"

F1SDK.SchedulerPage.UnscheduledOrdersGrid.getStore().storeId 
    // -> "UnscheduledWorkOrders"

F1SDK.SchedulerPage.UnscheduledOrdersGrid.getStore().data.items[0].internalId
F1SDK.SchedulerPage.UnscheduledOrdersGrid.selModel.selected.items[0].internalId

// Get a subgrid
FieldOneSkyUtils.Subgrid.GetSubgrid('id')

F1SDK.data.models.WorkOrder.getFields()
F1SDK.data.models.WorkOrder.getIdByWONumber('00106')           
     // -> {55caa97d-429a-e611-80e6-c4346bc4bef0}
Comments