ahmader / node-zoho

Zoho API access for NodeJS
21 stars 15 forks source link

Support for Setting wfTrigger #17

Closed idod closed 6 years ago

idod commented 8 years ago

Is there a way setting the wfTrigger to true using this API?

The regular Zoho request containing the above is something like: https://crm.zoho.com/crm/private/xml/Leads/insertRecords?authtoken=AuthToken&scope=crmapi&wfTrigger=true&xmlData=Your XML Data

How it can be done with this API?

Thanks !

ahmader commented 8 years ago

The wfTrigger is not provided in settings.

However, you can temporarily modify the file "./node-zoho/build/products/crm/crm-module.js"

  CrmModule.prototype.insertRecords = function(records, cb) {
    var options, query, request, url;
    if (!_.isArray(records)) {
      throw new Error('Requires array of records');
    }
    if (records.length < 1) {
      throw new Error('Requires as least one record');
    }
    query = {
      newFormat: 1,
      wfTrigger: true, // add here
      xmlData: this.build(records)
    };

You can do the same for updateRecords too.

idod commented 8 years ago

Works perfect.

Thanks !

ahmader commented 6 years ago

As of merge #32 now it is possible to pass optional query parameters.

This will be part of v0.0.32

var _query = {wfTrigger: true, newFormat: 1};
zoho.execute('crm', 'Leads', 'insertRecords', [_records], _query, function (err, result) {
  if (err !== null) {
    console.log(err);
  } else if (result.isError()) {
    console.log(result.message);
  } else {
    console.log(result.data);
  }
});