Hi A2Z Plumbing,
You can open your self-hosted price book in a popup inside ServiceM8 on the desktop web platform. However, there isn’t a supported manifest setting or Client JS SDK method to open it in an embedded browser inside the iPhone/iPad app instead of an external browser. App actions always use window; modal is supported only on the web platform.
Desktop: use a modal job action
Add an action with type: "online", entity: "job" and location: "modal". For an app button as well, add a separate type: "app" action, but that action uses window, not an embedded modal. Here’s an actions fragment for both platforms:
{
"actions": [
{
"name": "Price Book",
"type": "online",
"entity": "job",
"iconURL": "https://example.com/pricebook-icon.png",
"event": "open_pricebook",
"location": "modal"
},
{
"name": "Price Book",
"type": "app",
"entity": "job",
"iconURL": "https://example.com/pricebook-icon.png",
"event": "open_pricebook",
"location": "window"
}
]
}
For your self-hosted implementation, configure an HTTPS callback that accepts POST requests and returns your price book HTML. ServiceM8 renders the callback output in an iframe, so don’t set X-Frame-Options to a value that blocks embedding. Web-service-hosted add-ons also require OAuth2 authentication.
SDK methods
The manifest controls where the action opens; you don’t call an SDK method to launch the desktop modal. Include and initialise the Client JS SDK in your returned HTML, then use resizeWindow() and closeWindow() to manage the popup:
<script src="https://platform.servicem8.com/sdk/1.0/sdk.js"></script>
<script>
var client = SMClient.init();
client.resizeWindow(900, 650);
// When finished:
// client.closeWindow();
</script>
For iOS, the supported alternative is the external-window action, with a link back to ServiceM8 using https://go.servicem8.com/app/launch. There isn’t an SDK method to change that action into an in-app browser.
Adding selected items to the current job
Launch from a job action so your callback receives the current job’s UUID in eventArgs.jobUUID. On desktop, client.invoke(eventName, eventParams) can send the user’s selections back to your web service for processing. Your backend can create the selected line items with POST https://api.servicem8.com/api_1.0/jobmaterial.json, using that UUID as job_uuid and the OAuth scope manage_job_materials. This separates browsing your own price book from writing the chosen items to the ServiceM8 job.
Thanks,
Cody