แชร์ผ่าน


getEnabledProcesses (การอ้างอิง Client API)

เรียกใช้โฟลว์กระบวนการทางธุรกิจที่เปิดใช้งานสําหรับตารางที่ผู้ใช้ปัจจุบันสามารถสลับไปพร้อมกันได้

ไวยากรณ์

formContext.data.process.getEnabledProcesses(callbackFunction(enabledProcesses));

พารามิเตอร์

ชื่อ ประเภท ต้องมี คำอธิบาย
callbackFunction ฟังก์ชัน ใช่ ฟังก์ชันการเรียกกลับต้องยอมรับพารามิเตอร์ที่ประกอบด้วยวัตถุที่มีคุณสมบัติพจนานุกรม ซึ่งชื่อของคุณสมบัติคือ Id ของโฟลว์กระบวนการทางธุรกิจ และค่าของคุณสมบัติคือชื่อของโฟลว์กระบวนการทางธุรกิจ

กระบวนการที่เปิดใช้งานจะถูกกรองตามสิทธิ์การใช้งานของผู้ใช้ รายการของกระบวนการที่เปิดใช้งานเป็นแบบเดียวกันกับที่ผู้ใช้สามารถดูได้ใน UI ถ้าพวกเขาต้องการเปลี่ยนแปลงกระบวนการด้วยตนเอง

ตัวอย่าง

ฟังก์ชัน Sdk.formOnLoad ในตัวอย่างใช้เมธอด formContext.data.process.getEnabledProcesses เพื่อดึงข้อมูลแบบอะซิงโครนัสเกี่ยวกับโฟลว์กระบวนการทางธุรกิจที่เปิดใช้งานสําหรับตาราง ตัวอย่างจะส่งผ่านฟังก์ชันแบบไม่ระบุชื่อเป็นพารามิเตอร์แรก ฟังก์ชันนี้จะมีการดําเนินการแบบอะซิงโครนัสเมื่อมีการส่งกลับข้อมูลและข้อมูลจะถูกส่งผ่านเป็นพารามิเตอร์ไปยังฟังก์ชันแบบไม่ระบุชื่อ

ข้อมูลเกี่ยวกับโฟลว์กระบวนการทางธุรกิจที่เปิดใช้งานจะแสดงเป็นออบเจ็กต์พจนานุกรมซึ่งรหัสของกระบวนการคือชื่อของคุณสมบัติและชื่อของโฟลว์กระบวนการทางธุรกิจคือค่าของคุณสมบัติ โค้ดตัวอย่างจะประมวลผลข้อมูลนี้และตั้งค่าในอาร์เรย์ Sdk.enabledProcesses ส่วนกลางเพื่อเข้าถึงได้โดยตรรกะที่ดําเนินการในภายหลัง ตัวอย่างยังวนรอบผ่านค่าในอาร์เรย์ Sdk.enabledProcesses และใช้ฟังก์ชัน Sdk.writeToConsole เพื่อเขียนข้อมูลเกี่ยวกับโฟลว์กระบวนการทางธุรกิจที่เรียกใช้ไปยังคอนโซล

Note

ฟังก์ชัน Sdk.formOnLoad ในไลบรารี JavaScript ตัวอย่างต้องได้รับการตั้งค่าเป็นตัวจัดการเหตุการณ์ OnLoad สําหรับฟอร์ม และต้องเลือกกล่องกาเครื่องหมาย ส่งผ่านบริบทการดําเนินการเป็นพารามิเตอร์แรก ในกล่องโต้ตอบ คุณสมบัติตัวจัดการ
นอกจากนี้ ตัวอย่างนี้แสดงให้เห็นถึงการใช้บางวิธีใน formContext.data.process API ซึ่งไม่แสดงโดยใช้ API นี้เพื่อตอบสนองความต้องการทางธุรกิจ ซึ่งมีไว้เพื่อแสดงให้เห็นว่าสามารถเข้าถึงค่าคุณสมบัติหลักในโค้ดได้อย่างไร

//A namespace defined for SDK sample code
//You should define a unique namespace for your libraries
var Sdk = window.Sdk || {};
(function () {
    //A global variable to store information about enabled business processes after they are retrieved asynchronously
    this.enabledProcesses = [];

    // A function to log messages while debugging only
    this.writeToConsole = function (message) {
        if (typeof console != 'undefined')
        { console.log(message); }
    };

    // Code to run in the OnLoad event 
    this.formOnLoad = function (executionContext) {
        // Retrieve the formContext
        var formContext = executionContext.getFormContext();

        // Retrieve Enabled processes
        formContext.data.process.getEnabledProcesses(function (processes) {
            //Move processes to the global Sdk.enabledProcesses array;
            for (var processId in processes) {
                Sdk.enabledProcesses.push({ id: processId, name: processes[processId] })
            }
            Sdk.writeToConsole("Enabled business processes flows retrieved and added to Sdk.enabledProcesses array.");

            //Write the values of the Sdk.enabledProcesses array to the console
            if (Sdk.enabledProcesses.length < 0) {
                Sdk.writeToConsole("There are no enabled business process flows for this table.");
            }
            else {
                Sdk.writeToConsole("These are the enabled business process flows for this table:");
                for (var i = 0; i < Sdk.enabledProcesses.length; i++) {
                    var enabledProcess = Sdk.enabledProcesses[i];
                    Sdk.writeToConsole("id: " + enabledProcess.id + " name: " + enabledProcess.name)
                }
            }

            //Any code that depends on the Sdk.enabledProcesses array needs to be initiated here

        });
    };

}).call(Sdk);

เมื่อคุณเรียกใช้ตัวอย่างนี้ด้วยเครื่องมือสําหรับนักพัฒนาเบราว์เซอร์ ที่เปิดไว้ รายการต่อไปนี้คือตัวอย่างของเอาต์พุตที่เขียนไปยังคอนโซลสําหรับตารางที่มีการเปิดใช้งานโฟลว์กระบวนการทางธุรกิจหลายรายการ

Enabled business processes flows retrieved and added to Sdk.enabledProcesses array.
These are the enabled business process flows for this table:
id: 7994be68-899e-4a40-8d18-f5c3b6940188 name: Sample Lead Process
id: 919e14d1-6489-4852-abd0-a63a6ecaac5d name: Lead to Opportunity Sales Process

setActiveProcessInstance
formContext.data.process