qbo3 Task javascript - fetch identifiers

19 Views Asked by At

In a qbo3 Task's JavaScript, we have supplied a value for a Form Element:

document.id('FormEdit').getElement('input[name=Process_ProcessTemplateID]').value = '11';

but we need a way to have the '11' replaced by a Quandis query, like this:

SELECT [ProcessTemplate].[ProcessTemplateID] 
FROM ProcessTemplate 
WHERE [ProcessTemplate].[ProcessTemplate] LIKE ('MyProcessName')

so that the value from the ProcessTemplate table is used. Is there a way to do this with an API call, using a Promise or some other technique?

1

There are 1 best solutions below

0
On

You can do something like the following:

qbo3.getPromise = function(cn, method, data) {
  return new Promise(function(resolve, reject) {
    new (qbo3[cn] || qbo3[cn + 'Object'])().invokeJson(method, data, { success: resolve, error: reject });
  })
}

qbo3.getPromise('ProcessTemplate', 'Search', {"ProcessTemplate": "MyProcessName"})
  .then(json => {
    const id = json.ProcessCollection.ProcessItem[0].ProcessID;
    document.id('FormEdit').getElement('input[name=Process_ProcessTemplateID]').value = id;
  });