cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Fusion Lifecycle Extension for Visual Studio Code

Fusion Lifecycle Extension for Visual Studio Code

Would love to have an extension for Visual Studio Code to directly publish scripts to my tenant. Some extra built in FLC intellisense within the VSC environment would also be helpful.

 

The extension would need the ability to switch between the sandbox and production tenants.

 

 

5 Comments
john.denner
Advocate

Hi @ThomasRambach I think I might be able to help you with getting intellisense into the VSC environment. I taught this in my AU classes but the idea is pretty simple. You may already be aware of this but VSC looks at all the related files in your workspace for information. So what I've done is created a file that defines many of the properties (really just the ones I use and wasn't lazy enough to skip) and methods of FLC. 

 

For example here is what I've done with the Security object.

var Security = {
    /**
     * Checks if the user specified by userID is in the user group specified by groupName.
     * @example Security.inGroup('1234', 'ADMIN'); // true
     */
    inGroup: function inGroup(userID: string, groupName: string) {return true false},
    /**
     * Checks if the user specified by userID is assigned to the user role specified by 'ROLE_NAME'. 
     */
    inRole: function inRole(userID: string, roleName: string) {return true false},
    listGroups: function listGroups(userID: string) {return ['Group 1', 'Group 2']},
    listRoles: function listRoles(userID: string) {return ['Role 1', 'Role 2']},
};

Now when I type Security. I'll get a list of 4 methods to choose from. Additionally I'll get help text that will describe how the method works and what the expected parameters are.

 

2019-10-02_8-58-46.jpg

It can be a little tedious to build but if your interested I can give you everything I've done and you can do whatever you'd like with it. There's a version of it on GitHub but I haven't updated it and it was pretty specific to the classes.

 

ThomasRambach
Advisor

@john.dennerthat would be great to have a starting point. I guess I never really thought of doing it that way, it's brilliant. Does it have most of the out-of-the-box commands listed?

john.denner
Advocate

So it's a mix of around 80 methods and properties in total.

Things like

item.grid.addRow()
item.descriptor.createdDate item.project.children[i].progress() item.project.children[i].status item.workflowActions[i].transition.toState.customID

In the definition file you can go very simple by adding on to the item object with a simple property. Or you can add the property and define it further using jsDoc and assigning data types. By doing this you are adding to the help text you get when you hover over a keyword.

 

Here's my current definition file.

/* eslint-disable no-unused-vars, no-new-wrappers, no-shadow  */
/**
 * ## FLC Top Level Function
 * - Creates and Item Record in FLC
 * @param {string} wsID
 * @param {Object[]} [properties]
 * @returns {{object}}
 */
function createItem(wsID, properties) {}


/**
 * ## FLC Top Level Function
 * - Returns the workspace item specificed by dmsID. Deprecated.
 * @param {number} dmsID
 */
function loadItem(dmsID) {}

/**
 * ### item
 */
var item = {
    addMileStone: function addMileStone() {},
    deleteItem: function deleteItem() {},
    performWorkflowTransition: function performWorkflowTransition(transID, comment) {},
    /**
     * item.performWorkflowTransitionByCustomID('CUSTOM_ID', 'COMMENTS')
     * - Performs a workflow transition by its Custom ID as specified by 'CUSTOM_ID'.
     * - The 'COMMENTS' parameter is optional. If comments are specified, they are saved with the workflow step
     * in the Workflow Actions tab..
     * @param {string} customID
     * @param {string} [comments]
     */
    performWorkflowTransitionByCustomID: function performWorkflowTransitionByCustomID(customID, comments) {},
    /**
     * Descriptor properties on the item object (item.descriptor) represent item metadata.
     */
    descriptor: {
        createdBy: new String(),
        /**
         * System datetime (in the current users timezone?) that the record was created.
         */
        createdDate: new Date(),
        deleted: new Boolean(),
        descriptor: new Number(),
        lastModifiedOn: new Date(),
        ownerID: new String(),
        /**
         * Item's current state in the workflow.
         * @example
         * println(item.descriptor.workflowState);
         * // Work In Progress
         */
        workflowState: new String(),
        /** ### INCOMPLETE DEFINITION */
        dvi: {},
        /** ### INCOMPLETE DEFINITION */
        revisionList: [{}],
    },
    /**
     * - The item object Grid array (item.grid) is a standard JavaScript array of objects that represent individual rows
     * in the associated item's Grid tab. You get and set Grid row properties through field IDs the same way you access
     * Item Details fields (for example, item.grid[0].DESCRIPTION).
     * - You can assign values to Grid properties using properties on the item object. You can also assign values throug
     * variables declared in the script, including ones used to add other new rows. You can use this capability to add
     * multiple rows in a single script through cloning. You do not need to assign values to all fields in a row, only
     * to fields you want to populate.
     */
    grid: {
        /**
         * @param {{PHASE: string, STATUS: string, TASK_START: Date, TASK_END: Date, ASSIGNED_DEPARTMENT: string, ASSIGNED_USER: string, DETAILS: string}|{row}} row
         */
        addRow: function addRow(PHASE: string, STATUS: string, TASK_START: Date, TASK_END: Date, ASSIGNED_DEPARTMENT: string, ASSIGNED_USER: string, DETAILS: string) {},
        /**
         * ### `item.grid.clear()`
         * Empties the Grid array (removes all rows from the Grid tab)
         */
        clear: function clear() {},
        /**
         * ### !! Requires array item
         * ### `item.grid[i].remove()`
         * Removes the specified row in the array from the Grid tab
         */
        remove: function remove() {},
    },
    /**
     * ### item.project
     */
    project: {
        /**
         * ### addTask()
         * @example
         * // Adds a manual task (title) or a linked task (target) to the
         * // associated item's Project Management tab, passing task
         * // properties through properties on array objects.
         * item.project.addTask('title', start_date, end_date, 'progress');
         * item.project.addTask(target, start_date, end_date, 'progress');
         *
         * // Adds a manual or linked task to the associated item's
         * // Project Management tab, passing task properties in a task object.
         * item.project.addTask(task);
         */
        addTask: function addRelated() {},
        /**
         * Empties the tasks array (removes all tasks from the Project Management tab)
         */
        clear: function clear() {},
        /**
         * ### item.project.children[i] (JavaScript array)
         * Array of children of the specified task in the array (sub-tasks); only on tasks linked to
         * other project items (project tasks); children tasks can be manual, workflow/revision-controlled,
         * milestone, or other project tasks
         */
        children: [{
            /**
             * Percentage completed to date of the specified task in the array (% Complete on the Project Management tab)
             * @param {string} progress
             */
            progress: function progress(progress) {},
            /**
             * Removes the specified task in the array from the Project Management tab
             */
            remove: function remove() {},
            /**
             * ### item.project.children[i].status (string)
             * Status of the specified task in the array (Status on the Project Management tab)
             */
            status: '',
            duration: '',
            end_date: new Date(),
            /**
             * Number of the specified task in the array (#on the Project Management tab)
             */
            id: 123,
            owner: '',
            owner_descriptor: '',
            /**
             * dmsID of the item that owns the specified task in the array
             */
            owner_id: 123456,
            predecessors: [],
            priority: '',
            // progress: '',
            start_date: new Date(),
            state: '',
            subTasks: [],
            target: {},
            target_descriptor: '',
            target_id: 123456,
            title: '',
            type: '',
        }],
    },
    /**
     * ### item.relationships
     */
    relationships: {
        /**
         * ### addRelated()
         * @example
         * // Example
         * var workFlowItem = item.workflowItems.addItem({RELATED:targetItem, [...etc...] });
         */
        addRelated: function addRelated() {},
    },
    /**
     * ### item Workflow Actions array
     * The item object Workflow Actions array (item.workflowActions) is an array of workflow actions that have been
     * performed on the associated item. You can get workflow item values using properties on array objects.
     * - **Important:** The last performed workflow action is at the 0 index position in the array.
     */
    workflowActions: {
        /**
         * Comments saved with the specified workflow action in the array.
         * @example // Get the last transition comment.
         * println(item.workflowActions[0].comments);
         * // Hello world!
         */
        comments: '', // hi
        step: 123456789,
        /**
         * Date and time the specified workflow action in the array was performed.
         * @example
         * println(item.workflowActions[0].timeStamp);
         * // Thu Feb 01 2018 11:08:33 GMT-0500 (EST)
         */
        timeStamp: new Date(),
        /** Transition associated with the specified workflow action in the array */
        transition: {
            /** Custom ID of the transition. See State Properties in the Workflow Editor. */
            customID: '',
            shortName: '',
            userID: '',
            fromState: {
                customID: '',
                longName: '',
                shortName: '',
                stateID: 123456789,
            },
            toState: {
                customID: '',
                longName: '',
                shortName: '',
                stateID: 123456789,
            },
        },
    },
    /**
     * ### workFlowItems
     */
    workflowItems: {
        /**
         * ### addItem()
         * @example
         * // Example
         * var workFlowItem = item.workflowItems.addItem({RELATED:targetItem, [...etc...] });
         */
        addItem: function addItem() {},
        /**
         * ### clear()
         * Empties the workflow items array (removes all workflow items from the **Workflow Items** tab)
         * @example
         * item.workflowItems.clear();
         */
        clear: function clear() {},
        /**
         * ### !! Requires array item
         * ### .remove()
         * Removes the specified workflow item in the array from the **Workflow Items** tab
         * @example
         * item.workflowItems[i].remove();
         */
        remove: function remove() {},
        item: { ENTER_CUSTOM_FIELD_ID_HERE: '' },
        descriptor: '',
        id: 1234,
        lifecycle: '',
    },
    milestones: [{
        /**
         * Sets the workflow state of the milestone specified in the array
         * (item.milestones[i].workflowState property) to 'Workflow State Name', which takes
         * as its value the item's milestones[i].workflowState.workflowStateName property.
         * @param {string} wfStateName
         */
        setWorkflowState: function setWorkflowState(wfStateName) {},
        milestoneDate: '',
        milestoneType: '',
        progress: 123,
        warnThreshold: 123,
        worflowState: '',
        worflowStateName: '',
        worflowStateID: 123456,
    }],
};

var Security = {
    /**
     * Checks if the user specified by userID is in the user group specified by groupName.
     * @example Security.inGroup('1234', 'ADMIN'); // true
     */
    inGroup: function inGroup(userID: string, groupName: string) {return true false},
    /**
     * Checks if the user specified by userID is assigned to the user role specified by 'ROLE_NAME'. 
     */
    inRole: function inRole(userID: string, roleName: string) {return true false},
    listGroups: function listGroups(userID: string) {return ['Group 1', 'Group 2']},
    listRoles: function listRoles(userID: string) {return ['Role 1', 'Role 2']},
};
ThomasRambach
Advisor

Thanks @john.denner. It works perfectly.

john.denner
Advocate

Right on. It's pretty cool huh? I was so stoked when I learned we could do that. It's a long way from finished and there are some things we just can't do but it's saved me a lot of time. One limitation is we can't get code completion or jsDoc text on array items. For example item.workflowActions[0].transition.toState.customID. We get code completion and documentation for the green items but not the red. So the "workaround" is to get code hints from hovering over just workflowActions and it will tell you what can be done.

 

BTW this also works for your FLC library files. 🙂

 

2019-10-04_8-27-04.jpg

Can't find what you're looking for? Ask the community or share your knowledge.

Submit Idea