Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Offline persistence of formula field calculations

Please see previous discussion about formula fields and stale data.

...

WARNING: this can be an incredibly expensive and slow operation if you do not specify any filter criteria.  Therefore we recommend that you always include objectIds and/or whereClause parameters.

HTTP Callout API

The callout API is available for making HTTP(S) requests from the Pulsar platform and returning results to the HTML and javascript. Since custom HTML/javascript code is hosted as a local file within Pulsar, there can be issues using the normal XMLHttpRequest (XHR) or fetch methods to issue Cross-Origin requests to external services. This Pulsar API helps sidestep those problems.

Code Block
languagejs
var request = {
    type: 'callout',
    object: '',
    data: {
       resource: 'https://my.org.instance.salesforce.com/api/resources',
       options: {
           method: 'POST', // or GET, PUT, DELETE, etc...
           headers: { // header name-value pairs, as shown below
              Authorization: 'Bearer AABBEEAARREERRTTOOKKEENN....',
              Content-Type: 'application/json',
           },
           body: 'my post content body!',
       }
    }     
};
pulsarBridge.sendRequest(request, function (result) {
   if (result.type === 'calloutResponse') {
      var response = result.data;
      console.log('Response Status Code: '+response.status); // string
      console.log('Response Data:'+response.body); // string
      
   }
   else {
      console.log('failed: '+ result.data)
   }
});

Communicating with the Home App

Pulsar allows for the development of a Home Appthat runs in place of the usual native Pulsar application. Pulsar Field Service Lightning is an example of one such Home App. When developing custom documents, it may be useful to communicate with the Home App through the dispatchtohomeappAPI.

Pulsar FSL Examples

Code Block
languagejs
// Go Home -- dismiss all open native Pulsar pages and documents and navigate FSL to the schedule screen and select today's date //
var goHomeRequest = {
  type: 'dispatchtohomeapp',
  object: '',
  data: {
    action: 'goHome',
    parameters: {},
  },
}

pulsarBridge.sendRequest(goHomeRequest, function (result) {
  if (result.type == 'dispatchtohomeappResponse') {
    // handle the success case //
    // the 'goHome' action tells Pulsar FSL to dismiss all native pages (possibly including the one sending this message)
    // and navigate to the Schedule page with today's date selected. 
    console.log('PulsarFSL navigated to the Home Screen');
  } else {
    // This may happen if the format of your data block in the request is unhandled or malformed. //
    console.log('PulsarFSL failed to handle goHome action: ', result.data);
  }   
});

// View Object - the 'view' action allows for direct navigation to objects in the FSL context. It is important to note that many SObject types 
// are not handled by FSL and may result in undesired behavior. Valid parameters for the object field are 'ServiceAppointment', 'WorkOrder',
// and 'WorkOrderLineItem'. 
var viewRequest = {
  type: 'dispatchtohomeapp',
  object: '',
  data: {
    action: 'view',
    parameters: {
      object: 'WorkOrder',
      Id: 'aValidWorkOrderId',      
    },
  },
};

pulsarBridge.sendRequest(viewRequest, function (result) {
if (result.type == 'dispatchtohomeappResponse') {
    // handle the success case //
    // the 'view' action tells Pulsar FSL to navigate to the provided object's overview page within FSL.
    console.log('PulsarFSL attempted to navigate to the page.');
  } else {
    // This may happen if the format of your data block in the request is unhandled or malformed. //
    console.log('PulsarFSL failed to handle view action: ', result.data);
  } 
});

Custom Home App Examples

When interacting with your own custom home app, you are responsible for handling all dispatchtohomeapp interaction. This is achieved through a registration API call: registerdispatchtohomeapp. The following example comes from our own Pulsar FSL application. After we have access to the Pulsar bridge object we perform some custom setup to handle messaging from other documents and our own internal messaging.

...