Versions Compared

Key

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

...

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);
  } 
});

...