0

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?

Eric Patrick
  • 2,097
  • 2
  • 20
  • 31

1 Answers1

0

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;
  });
Eric Patrick
  • 2,097
  • 2
  • 20
  • 31