Documentation - PaulNieuwelaar/processjsext GitHub Wiki

Installation & Usage

  1. Download and install the unmanaged solution for Process.js Extensions (recommended).
  2. Download and install Process.js, which is used to call these actions.
  3. Make sure to publish all customizations if installing the unmanaged solutions.
  4. Create a new JavaScript web resource or use an existing web resource to create your custom functions which will call the process.js functions.
  5. Add a reference to the process.js web resource on your form or view.
    • For forms, this is simply added through the form properties.
    • For views, add a "JavaScript Function Action" to the "Command Actions" for your button command, calling the process.js web resource, where the function is "isNaN" (without quotes). Using the Ribbon Workbench to edit the command is recommended.
  6. Add a reference to your custom JavaScript web resource where you're making the calls to process.js. This should be added after the reference to process.js.
  7. Call your custom function from your JavaScript library, e.g. from the command bar button, or from the form onload event.

Actions included

Associate

Associates two records via an existing N:N relationship.

Process.callAction("mag_Associate",
    [{
        key: "Target",
        type: Process.Type.EntityReference,
        value: new Process.EntityReference("account", "F77E9AEB-A341-E711-80C2-00155D048D79")
    },
    {
        key: "RelatedEntity",
        type: Process.Type.EntityReference,
        value: new Process.EntityReference("contact", "FA4F0602-0314-E711-80C0-00155D048D79")
    },
    {
        key: "Relationship",
        type: Process.Type.String,
        value: "mag_account_contact"
    }],
    function () {
        alert("Associate completed");
    },
    function (error, trace) {
        alert(error);
    });

Input Parameters

Target

  • Type: EntityReference. The primary record to associate with.
new Process.EntityReference("account", "F77E9AEB-A341-E711-80C2-00155D048D79")

RelatedEntity

  • Type: EntityReference. The secondary record to associate with.
new Process.EntityReference("contact", "FA4F0602-0314-E711-80C0-00155D048D79")

Relationship

  • Type: String. The name of the relationship.
"mag_account_contact"

Create

Creates an instance of an entity and returns the ID of the new record.

Process.callAction("mag_Create",
    [{
        key: "Target",
        type: Process.Type.Entity,
        value: new Process.Entity("account", "507b6ae5-93f3-41c0-9694-2818da155a6d", // Specify new GUID or leave null for CRM to assign
            {
                "name": new Process.Attribute("New Account", Process.Type.String),
                "accountnumber": new Process.Attribute("12345", Process.Type.String)
            })
    }],
    function (params) {
        var id = params["Id"];
        alert(id);
    },
    function (error, trace) {
        alert(error);
    });

Input Parameters

Target

  • Type: Entity. The record to be created.
new Process.Entity("account", "507b6ae5-93f3-41c0-9694-2818da155a6d", // Specify new GUID or leave null for CRM to assign
    {
        "name": new Process.Attribute("New Account", Process.Type.String),
        "accountnumber": new Process.Attribute("12345", Process.Type.String)
    })

Output Parameters

Id

  • Type: String. The GUID of the created record.
var id = params["Id"];
alert(id);

CreateMultiple

Creates multiple records at once. These can be for the same entity, or different entities. The ID's of the created records are not returned.

Process.callAction("mag_CreateMultiple",
    [{
        key: "Entities",
        type: Process.Type.EntityCollection,
        value: [new Process.Entity("account", null, // Specify new GUID or leave null for CRM to assign
            {
                "name": new Process.Attribute("New Account", Process.Type.String),
                "accountnumber": new Process.Attribute("12345", Process.Type.String)
            }),
            new Process.Entity("contact", "276ae2d6-0c34-4144-b92b-f766e8fd54a5", // Specify new GUID or leave null for CRM to assign
            {
                "firstname": new Process.Attribute("Frosty", Process.Type.String),
                "emailaddress1": new Process.Attribute("[email protected]", Process.Type.String)
            })]
    }],
    function () {
        alert("CreateMultiple completed");
    },
    function (error, trace) {
        alert(error);
    });

Input Parameters

Entities

  • Type: EntityCollection. Collection of entities to create.
[new Process.Entity("account", null, // Specify new GUID or leave null for CRM to assign
    {
        "name": new Process.Attribute("New Account", Process.Type.String),
        "accountnumber": new Process.Attribute("12345", Process.Type.String)
    }),
    new Process.Entity("contact", "276ae2d6-0c34-4144-b92b-f766e8fd54a5", // Specify new GUID or leave null for CRM to assign
    {
        "firstname": new Process.Attribute("Frosty", Process.Type.String),
        "emailaddress1": new Process.Attribute("[email protected]", Process.Type.String)
    })]

Delete

Permanently deletes a record from the system.

Process.callAction("mag_Delete",
    [{
        key: "Target",
        type: Process.Type.EntityReference,
        value: new Process.EntityReference("contact", "276ae2d6-0c34-4144-b92b-f766e8fd54a5")
    }],
    function () {
        alert("Delete completed");
    },
    function (error, trace) {
        alert(error);
    });

Input Parameters

Target

  • Type: EntityReference. The record to delete.
new Process.EntityReference("contact", "276ae2d6-0c34-4144-b92b-f766e8fd54a5")

Disassociate

Associates two records via an existing N:N relationship.

Process.callAction("mag_Disassociate",
    [{
        key: "Target",
        type: Process.Type.EntityReference,
        value: new Process.EntityReference("account", "F77E9AEB-A341-E711-80C2-00155D048D79")
    },
    {
        key: "RelatedEntity",
        type: Process.Type.EntityReference,
        value: new Process.EntityReference("contact", "FA4F0602-0314-E711-80C0-00155D048D79")
    },
    {
        key: "Relationship",
        type: Process.Type.String,
        value: "mag_account_contact"
    }],
    function () {
        alert("Disassociate completed");
    },
    function (error, trace) {
        alert(error);
    });

Input Parameters

Target

  • Type: EntityReference. The primary record to disassociate with.
new Process.EntityReference("account", "F77E9AEB-A341-E711-80C2-00155D048D79")

RelatedEntity

  • Type: EntityReference. The secondary record to disassociate with.
new Process.EntityReference("contact", "FA4F0602-0314-E711-80C0-00155D048D79")

Relationship

  • Type: String. The name of the relationship.
"mag_account_contact"

Retrieve

Retrieves a single record from the system by specifying the GUID of the record to retrieve, and the columns for that record.

Process.callAction("mag_Retrieve",
    [{
        key: "Target",
        type: Process.Type.EntityReference,
        value: new Process.EntityReference("account", "F77E9AEB-A341-E711-80C2-00155D048D79")
    },
    {
        key: "ColumnSet",
        type: Process.Type.String,
        value: "name,ownerid"
    }],
    function (params) {
        var result = params["Entity"];
        if (result != null) {
            var name = result.get("name");
            var owner = result.get("ownerid").name;
            alert("Name: " + name + ", Owner: " + owner);
        }
    },
    function (error, trace) {
        alert(error);
    });

Input Parameters

Target

  • Type: EntityReference. The record to retrieve.
new Process.EntityReference("account", "F77E9AEB-A341-E711-80C2-00155D048D79")

ColumnSet

  • Type: String. Comma separated list of fields to retrieve. Leave null to get all columns.
"name,ownerid"

Output Parameters

Entity

  • Type: Entity. The entity containing the specified columns.
var result = params["Entity"];
if (result != null) {
    var name = result.get("name");
    var owner = result.get("ownerid").name;
    alert("Name: " + name + ", Owner: " + owner);
}

RetrieveMultiple

Retrieves a collection of records from the system using the passed in FetchXML query.

Process.callAction("mag_RetrieveMultiple",
    [{
        key: "Query",
        type: Process.Type.String,
        value: "<fetch><entity name='account'><attribute name='name' /></entity></fetch>"
    }],
    function (params) {
        var results = params["EntityCollection"];
        if (results != null && results.length > 0) {
            var name = results[0].get("name");
            alert(name);
        }
    },
    function (error, trace) {
        alert(error);
    });

Input Parameters

Query

  • Type: String. The fetch XML query to execute.
"<fetch><entity name='account'><attribute name='name' /></entity></fetch>"

Output Parameters

EntityCollection

  • Type: EntityCollection. The entity collection containing the results from the fetch XML query.
var results = params["EntityCollection"];
if (results != null && results.length > 0) {
    var name = results[0].get("name");
    alert(name);
}

SetState

Sets the status and/or status reason of a record.

Process.callAction("mag_SetState",
    [{
        key: "EntityMoniker",
        type: Process.Type.EntityReference,
        value: new Process.EntityReference("account", "F77E9AEB-A341-E711-80C2-00155D048D79")
    },
    {
        key: "State",
        type: Process.Type.Int,
        value: 1 // Inactive
    },
    {
        key: "Status",
        type: Process.Type.Int,
        value: -1 // Default
    }],
    function () {
        alert("SetState completed");
    },
    function (error, trace) {
        alert(error);
    });

Input Parameters

EntityMoniker

  • Type: EntityReference. The record to update.
new Process.EntityReference("account", "F77E9AEB-A341-E711-80C2-00155D048D79")

State

  • Type: Integer. The new status of the record.
1

Status

  • Type: Integer. The new status reason of the record.
-1

Update

Updates an existing record.

Process.callAction("mag_Update",
    [{
        key: "Target",
        type: Process.Type.Entity,
        value: new Process.Entity("account", "F77E9AEB-A341-E711-80C2-00155D048D79",
            {
                "name": new Process.Attribute("Updated Account", Process.Type.String),
                "accountnumber": new Process.Attribute("12345", Process.Type.String)
            })
    }],
    function () {
        alert("Update completed");
    },
    function (error, trace) {
        alert(error);
    });

Input Parameters

Target

  • Type: Entity. The record including attributes to update.
new Process.Entity("account", "F77E9AEB-A341-E711-80C2-00155D048D79",
    {
        "name": new Process.Attribute("Updated Account", Process.Type.String),
        "accountnumber": new Process.Attribute("12345", Process.Type.String)
    })

UpdateMultiple

Updates multiple records at once. These can be of the same entity type or different.

Process.callAction("mag_UpdateMultiple",
    [{
        key: "Entities",
        type: Process.Type.EntityCollection,
        value: [new Process.Entity("account", "F77E9AEB-A341-E711-80C2-00155D048D79",
            {
                "name": new Process.Attribute("Updated Account", Process.Type.String),
                "accountnumber": new Process.Attribute("12345", Process.Type.String)
            }),
            new Process.Entity("contact", "FA4F0602-0314-E711-80C0-00155D048D79",
            {
                "firstname": new Process.Attribute("Frosty", Process.Type.String),
                "emailaddress1": new Process.Attribute("[email protected]", Process.Type.String)
            })]
    }],
    function () {
        alert("UpdateMultiple completed");
    },
    function (error, trace) {
        alert(error);
    });

Input Parameters

Entities

  • Type: EntityCollection. A collection of entities to update.
[new Process.Entity("account", "F77E9AEB-A341-E711-80C2-00155D048D79",
    {
        "name": new Process.Attribute("Updated Account", Process.Type.String),
        "accountnumber": new Process.Attribute("12345", Process.Type.String)
    }),
    new Process.Entity("contact", "FA4F0602-0314-E711-80C0-00155D048D79",
    {
        "firstname": new Process.Attribute("Frosty", Process.Type.String),
        "emailaddress1": new Process.Attribute("[email protected]", Process.Type.String)
    })]
⚠️ **GitHub.com Fallback** ⚠️