ContextSearchForString

Searches for string in a path in context. If path is null, string will be searched in full context.

javascript · Common Scripts

Source

var path = args.path;
var str = args.str;
var flat={};

function searchString(obj) {
    flattenFields(obj,undefined,flat);
    keysArr = Object.keys(flat);
    for (i = 0; i < keysArr.length - 1; i++) {
        if (flat[keysArr[i]] === str) {
            return true;
        }
    }
    return false;
}

if (!path) {
    return searchString(invContext);
}

var contextObject = dq(invContext, path);

if (!contextObject) {
    throw 'Path ' + path + ' is not in the context.';
}

return searchString(contextObject);


README

Searches for a string in a path in context. If path is null, the string will be searched in full context.

Script Data


Name Description
Script Type javascript
Tags  

Inputs


Argument Name Description
path The path in context to search the string in.
str The string to search for in context.

Outputs


Path Description Type
True Whether the given string exists in context. Unknown
False Whether the given string does not exist in context. Unknown