Hierarchy

  • OmniScriptAccess

Constructors

Properties

salesforceService: SalesforceService

Methods

  • Enhance OmniScript records by attaching their related element records. This creates a complete representation of the OmniScript with its structure and components.

    This method is useful when you need to process an OmniScript's full definition, including all its elements, their hierarchies, and property sets.

    Parameters

    • scripts: OmniScriptRecord

      Single OmniScript record or array of OmniScript records to enhance

    Returns Promise<OmniScriptWithElementsRecord>

    OmniScript records with their elements attached in an 'elements' property

    Example

    // Attach elements to a single script
    const script = await omniScriptAccess.find('a1r3X000000ABCDEFG');
    const scriptWithElements = await omniScriptAccess.attachElements(script);
    console.log(`Script has ${scriptWithElements.elements.length} elements`);

    Example

    // Attach elements to multiple scripts at once (more efficient)
    const scripts = await omniScriptAccess.filter({ type: 'Account' });
    const scriptsWithElements = await omniScriptAccess.attachElements(scripts);
    scriptsWithElements.forEach(script => {
    console.log(`${script.type}/${script.subType} has ${script.elements.length} elements`);
    });
  • Parameters

    Returns Promise<OmniScriptWithElementsRecord[]>

  • Retrieve OmniScript elements matching the specified filter criteria. This method queries both OmniProcess and OmniScript element records and combines the results.

    Parameters

    • filter: OmniScriptElementFilter

      Criteria to filter elements: - scriptId: Limit to elements from specific script(s) - type: Filter by element type(s) like 'Step', 'Block', 'OmniScript', etc. - active: When true, only return elements from active scripts

    Returns Promise<OmniScriptElementRecord[]>

    Array of OmniScript element records matching the filter

    Example

    // Get all elements from a specific script
    const scriptElements = await omniScriptAccess.elements({
    scriptId: 'a1r3X000000ABCDEFG'
    });

    Example

    // Get all OmniScript elements (embedded scripts) from active scripts
    const embeddedScripts = await omniScriptAccess.elements({
    type: 'OmniScript',
    active: true
    });

    Example

    // Get all Step elements from multiple scripts
    const steps = await omniScriptAccess.elements({
    scriptId: ['a1r3X000000ABCDEFG', 'a1r3X000000HIJKLMN'],
    type: 'Step'
    });
  • Filter OmniScripts based on specified criteria. This method searches across both OmniProcess and OmniScript SObjects and returns matching records.

    Parameters

    • filter: OmniScriptIdentifier

      Optional filter criteria to search for OmniScripts. Can be a string ID, or an object with type, subType, language, version, and/or active properties.

    • options: OmniScriptFilterOptions & {
          withElements: true;
      }

      Optional settings to control the returned data

    Returns Promise<OmniScriptWithElementsRecord[]>

    Array of OmniScript records matching the filter criteria

    Example

    // Find all active scripts of a specific type
    const activeScripts = await omniScriptAccess.filter({
    type: 'Account',
    active: true
    });

    Example

    // Find all versions of a specific script
    const scriptVersions = await omniScriptAccess.filter({
    type: 'Account',
    subType: 'Creation',
    language: 'English'
    });

    Example

    // Find scripts with their elements
    const scriptsWithElements = await omniScriptAccess.filter(
    { type: 'Account' },
    { withElements: true }
    );
  • Parameters

    Returns Promise<OmniScriptRecord[]>

  • Find a specific OmniScript record based on the provided identifier. This method looks through both OmniProcess and OmniScript SObjects and returns the matching record. If multiple records match the criteria, it will return the first one found (typically the one with the highest version number).

    Parameters

    • id: OmniScriptIdentifier

      OmniScript identifier - can be a string ID or an object with type, subType, language, etc.

    • options: OmniScriptFindOptions & {
          withElements: true;
      }

      Optional settings: - withElements: When true, includes element records as part of the result - preferActive: When true, prioritizes active versions over exact ID matches

    Returns Promise<OmniScriptWithElementsRecord>

    The matching OmniScript record

    Throws

    Error if no matching OmniScript record is found

    Example

    // Find script by Salesforce record ID
    const scriptById = await omniScriptAccess.find('a1r3X000000ABCDEFG');

    Example

    // Find active version of a script by type information
    const activeScript = await omniScriptAccess.find({
    type: 'Account',
    subType: 'Creation',
    language: 'English',
    active: true
    });

    Example

    // Find script with all its elements
    const scriptWithElements = await omniScriptAccess.find(
    'a1r3X000000ABCDEFG',
    { withElements: true }
    );
  • Parameters

    Returns Promise<OmniScriptRecord>

  • Find active scripts that depend on the given script. This method is useful when you need to know which scripts use the provided script as an embedded subcomponent.

    When a script is configured as reusable, it can be embedded in other scripts. This method helps identify those parent scripts that would be affected by changes to the given script.

    Parameters

    Returns Promise<string[]>

    Array of script IDs that depend on (embed) the provided script

    Example

    // Find which active scripts are using a reusable script
    const dependentScriptIds = await omniScriptAccess.findActiveDependentScripts({
    type: 'ReusableComponent',
    subType: 'Address',
    language: 'English'
    });

    // Then you can load those scripts if needed
    const dependentScripts = await Promise.all(
    dependentScriptIds.map(id => omniScriptAccess.find(id))
    );
  • Get all activated template records for the specified template names. This method retrieves Vlocity UI Templates that are used by OmniScripts, primarily for custom Lightning Web Components or custom HTML templates.

    This method only returns templates that are marked as active in the org.

    Parameters

    • names: string[]

      Array of template names to retrieve

    Returns Promise<Map<string, VlocityUITemplateRecord>>

    Map of template names to their corresponding template records for easy lookup

    Example

    // Find active templates used in a script
    const templateNames = ['MyCustomTemplate', 'CommonHeader', 'Footer'];
    const templates = await omniScriptAccess.findActiveTemplates(templateNames);

    if (templates.has('MyCustomTemplate')) {
    const template = templates.get('MyCustomTemplate');
    console.log(`Template HTML: ${template.html}`);
    } else {
    console.log('Template not found or not active');
    }