The calls that support Pulsar native screen interaction need to know that you will only see the response when the native screen is dismissed by the user. For example, if your code calls |
The |
var request = { "type" : "setLeavePageMessage", "object" : "", "data" : "Are you sure you want to leave this page?" // message displayed in a yes/no confirmation alert }; bridge.send(request, function (responseData) { alert('Javascript got its view response: ' + responseData); }); |
The |
var request = { "type" : "exit", "data" : {} }; bridge.send(request, function (responseData) { console.log('exit: ' + responseData); }); |
The "createResult" --- boolean success flag ("TRUE" or "FALSE") "createId" -- the created object Id, if the create was successful |
var request = { "type" : "showCreate", "object" : "Account", "data" : { "Name" : "John Doe Industries", "Phone" : "867-5309" } }; bridge.send(request, function(responseData) { if (responseData.type === "showcreateResponse" && responseData.data.createResult === "TRUE") { alert('Create Success! ObjectId: ' + responseData.data.createId); } else { alert('Error during create: ' + responseData.data); } }); |
The |
var request = { "type" : "viewObject", "object" : "Account", "data" : { "Id" : "00123456789ABCD", // This will open the Account object with this Id "editmode" : "1" // OPTIONAL: allows the object to be opened in edit mode } }; bridge.send(request, function (responseData) { if (responseData.type === "viewResponse") { success(responseData.data); } else if (responseData.type == 'error') { failure(responseData.data); } }); |
The Note: You should use the API name of the child relationship. You can get this information from Workbench by doing a describe object call and expanding ChildRelationships element. |
var request = { "type" : "viewRelated", "object" : "Account", "data" : { "Id" : "001234567891234", "relationshipName" : "Contacts" } // Open the Contacts related list for the specified Account object }; bridge.send(request, function (responseData) { if (responseData.type === "viewResponse") { success(responseData.data); } else if (responseData.type == 'error') { failure(responseData.data); } }); |
The |
var request = { "type" : "viewList", "object" : "Account", "data" : { "@@listviewid" : "00B123456789101" } }; bridge.send(request, function(responseData) { if (responseData.type === "viewListResponse") { success(responseData.data); } else if (responseData.type == 'error') { failure(responseData.data); } }); |
The Two options for the data portion of the request:
|
var request = { "type" : "lookupObject", "object" : "Account", "data" : { "Type" : "Prospect" } // This is optional. This will open the list for Account objects with type "Prospect" }; bridge.send(request, function (responseData) { if ((responseData.type == 'lookupObjectResponse') && (responseData.data != null)) { alert('selected object: ' + responseData.data[0]); } }); |
The |
var request = { "type" : "scanBarcode", "data" : { /* data is empty */ } }; bridge.send(request, function (responseData) { if ((responseData.type == 'scanBarcodeResponse') && (responseData.data != null)) { alert('scanned barcode: ' + responseData.data.barcode); } }); |
The |
var request = { 'type' : 'executeQuickAction', 'data' : { 'ActionName': 'UpdateCustomObject', /* (Required) The Quick Action's Salesforce API name */ 'ContextId' : '00123456789ABCDEFG', /* (Optional) The Id of the object related to the quick action's target object, if any */ 'Field1' : 'Value1', /* (Optional) Any number of field values to be supplied as defaults to the target object of the quickaction */ 'Field2' : 'Value2', } }; bridge.send(request, function(responseData) { if ((responseData.type === 'executeQuickActionResponse') && (responseData.data != null)) { var responseObject = responseData.data; /* the response object contains two properties: 1. "executed" : the execution state of the quick action- true if the quick action was presented to the user. false otherwise 2. "quickActionResult" : a flag representing whether the quickaction saved/created the target object- true if successful, false if failed. */ } else { // handle the API error or cancellation ... } }); |
The |
var request = { 'type' : 'getQuickActions', 'object' : 'Account', /* (Required) The associated SObject API name, or 'Global' */ 'data' : { 'RecordTypeName': 'CustomRecordType', /* (Optional) The RecordType DeveloperName (API Name) for the desired SObject's page layout */ 'RecordTypeId' : '0123456789ABCDEFGH' /* (Optional) The RecordType Id for the desired SObject's page layout */ } }; bridge.send(request, function(responseData) { if ((responseData.type === 'quickactionsResponse') && (responseData.data != null)) { var quickActionArray = responseData.data; /* the response array contains QuickAction metadata */ } else { // handle the API error or cancellation ... } }); |
The |
var request = { "type" : "cameraPhoto", "data" : { "quality" : "medium" // optional parameter} }; bridge.send(request, function (responseData) { if ((responseData.type == 'cameraPhotoResponse') && (responseData.data != null)) { var filePath = responseData.data.FilePath; var fileUrl = responseData.data.FileURL; // new for 6.0 var relativePath = responseData.data.RelativeFilePath; // new for 6.0 var contentType = responseData.data.ContentType; alert('camera photo path: ' + filePath + ' content type: ' + contentType); } }); |
The |
var request = { 'type' = 'cameraPhotoPicker', 'data' : { /* data is empty */ } }; bridge.send(request, function(responseData) { if ((responseData.type === 'cameraPhotoPickerResponse') && (responseData.data != null)) { var arrResult = responseData.data; var len = arrResult.length; for (var i=0; i<len; i++) { var filePath = arrResult[i].FilePath; var fileUrl = arrResult[i].FileURL; // new for 6.0 var relativePath = arrResult[i].RelativeFilePath; // new for 6.0 var contentType = arrResult[i].ContentType; console.log('camera photo path: ' + filePath + ' content type: ' + contentType); // ... } } else { // handle error or cancellation ... } }); |
The |
var request = { 'type' : 'filePicker', 'data' : { /* data is empty */ } }; bridge.send(request, function(responseData) { if ((responseData.type === 'filePickerResponse') && (responseData.data != null)) { var arrResult = responseData.data; var len = arrResult.length; for (var i=0; i<len; i++) { var filePath = arrResult[i].FilePath; var fileUrl = arrResult[i].FileURL; // new for 6.0 var relativePath = arrResult[i].RelativeFilePath; // new for 6.0 var contentType = arrResult[i].ContentType; console.log('camera photo path: ' + filePath + ' content type: ' + contentType); // ... } } else { // handle error or cancellation ... } }); |
The
will become: param1=value1¶m2=value2 |
On Android, Pulsar will always attempt to open unencrypted HTTP URLs ("http://" without the "s") in an external browser app. This is due to security restrictions in place for the Android operating system. |
// open a webview with the url "https://example.com/path/to/resource/?param1=value1¶m2=value2 var request = { "type" : "displayUrl", "data" : { "externalBrowser" : true, "scheme" : "https://", "path" : "example.com/path/to/resource", "queryParams" : { "param1": "value1", "param2": "value2" } } }; bridge.send(request, function (responseData) { if ((responseData.type !== 'displayUrlResponse') && (responseData.data != null)) { alert('Error occurred: ' + responseData.data); } }); |