lib/impl/updateForm.js
function getFormDataSources(formJSON) {
    var dataSources;
    var pages = formJSON.pages || [];
    dataSources = _.map(pages, function(page) {
      var fields = page.fields || [];

      fields = _.map(fields, function(field) {
        //If the field is defined as a Data Source field, and it has a data source, then return that data source.
        if (field.dataSourceType === models.FORM_CONSTANTS.DATA_SOURCE_TYPE_DATA_SOURCE && field.dataSource) {
          return field.dataSource;
        } else {
          return undefined;
        }
      });

      //Removing any undefined values
      return _.compact(fields);
    });

    //Remove all nested arrays
    dataSources = _.flatten(dataSources);

    logger.debug("Got Form Data Sources", dataSources);

    //Only Want One Of Each Data Source
    return _.uniq(dataSources);
  }
function getFormDataSources(formJSON) {
    var dataSources;
    var pages = formJSON.pages || [];
    dataSources = _.map(pages, function(page) {
      var fields = page.fields || [];

      fields = _.map(fields, function(field) {
        //If the field is defined as a Data Source field, and it has a data source, then return that data source.
        if (field.dataSourceType === models.FORM_CONSTANTS.DATA_SOURCE_TYPE_DATA_SOURCE && field.dataSource) {
          return field.dataSource;
        } else {
          return undefined;
        }
      });

      //Removing any undefined values
      return _.compact(fields);
    });

    //Remove all nested arrays
    dataSources = _.flatten(dataSources);

    logger.debug("Got Form Data Sources", dataSources);

    //Only Want One Of Each Data Source
    return _.uniq(dataSources);
  }
function getFormDataSources ( formJSON ) { var dataSources ; var pages = formJSON . pages || [ ] ; dataSources = _ . map ( pages , function ( page ) { var fields = page . fields || [ ] ; fields = _ . map ( fields , function ( field ) { //If the field is defined as a Data Source field, and it has a data source, then return that data source. if ( field . dataSourceType === models . FORM_CONSTANTS . DATA_SOURCE_TYPE_DATA_SOURCE && field . dataSource ) { return field . dataSource ; } else { return undefined ; } } ) ; //Removing any undefined values return _ . compact ( fields ) ; } ) ; //Remove all nested arrays dataSources = _ . flatten ( dataSources ) ; logger . debug ( "Got Form Data Sources" , dataSources ) ; //Only Want One Of Each Data Source return _ . uniq ( dataSources ) ; }
Extracting any data sources that are contained in any field in the forms.
Will only return unique entries
@param formJSON -- JSON Definition Of The Form
Extracting any data sources that are contained in any field in the forms . Will only return unique entries