Skip to content

Instantly share code, notes, and snippets.

View cgillis-aras's full-sized avatar

Chris Gillis cgillis-aras

View GitHub Profile
@cgillis-aras
cgillis-aras / AttributeShorthandFunctions.cs
Created January 11, 2021 20:41
Examples of the specific attribute shorthand functions in Aras Innovator.
Innovator inn = this.getInnovator();
Item part = inn.newItem();
/* All of the pairs of functions below are equivalent */
// Set the type attribute
part.setAttribute("type", "Part");
part.setType("Part");
// Set the action attribute
part.setAttribute("action", "get");
@cgillis-aras
cgillis-aras / RequestWithCountOnly.cs
Created December 16, 2020 20:44
An example of a method in Aras Innovator that makes a get request while using the returnMode attribute with a value of countOnly
Innovator inn = this.getInnovator();
Item newPart = inn.newItem("Part", "get");
newPart.setAttribute("returnMode", "countOnly");
newPart.setAttribute("page", "1");
newPart.setAttribute("pagesize", "10");
newPart = newPart.apply();
// The results when using returnMode="countOnly" look different than a normal item,
// so we need to retrieve them in a different way.
@cgillis-aras
cgillis-aras / RequestWithDoGetItem.cs
Created December 16, 2020 20:09
An example of a method inside of Aras Innovator that adds an item while using the doGetItem attribute
Innovator inn = this.getInnovator();
Item newPart = inn.newItem("Part", "add");
newPart.setProperty("item_number", "New Part 1");
newPart.setAttribute("doGetItem", "0");
newPart = newPart.apply();
// You can still validate the response when using doGetItem
if (newPart.isError())
{
@cgillis-aras
cgillis-aras / cui_reinit_calc_tearoff_states.js
Created November 8, 2019 14:45
Copy of the cui_reinit_calc_tearoff_states JavaScript method in Aras Innovator
var eventState = {};
var topWindow = aras.getMostTopWindowWithAras(window);
var item = topWindow.item;
var itemType = topWindow.itemType;
if (item) {
var itemTypeName = topWindow.itemTypeName;
var isTemp = aras.isTempEx(item);
var isDirty = aras.isDirtyEx(item);
var isNew = aras.isNew(item);
var lockedBy = aras.getItemProperty(item, 'locked_by_id', '');
@cgillis-aras
cgillis-aras / cui_reinit_calc_tearoff_states.js
Created November 8, 2019 14:45
Copy of the cui_reinit_calc_tearoff_states JavaScript method in Aras Innovator
var eventState = {};
var topWindow = aras.getMostTopWindowWithAras(window);
var item = topWindow.item;
var itemType = topWindow.itemType;
if (item) {
var itemTypeName = topWindow.itemTypeName;
var isTemp = aras.isTempEx(item);
var isDirty = aras.isDirtyEx(item);
var isNew = aras.isNew(item);
var lockedBy = aras.getItemProperty(item, 'locked_by_id', '');
@cgillis-aras
cgillis-aras / araslabs_ShowMyGraph.js
Last active November 5, 2019 19:32 — forked from EliJDonahue/araslabs_ShowMyGraph.js
Sample method code for opening a specific graph view
// For 11.0 SP15
return ModulesManager.using(
['aras.innovator.GraphView/GraphWindowView',
'aras.innovator.core.ItemWindow/DefaultItemWindowCreator'
]).then(function (View, Creator) {
require(['GraphView/Scripts/GraphDataLoader'], function (GraphDataLoader) {
inArgs = {
// Specify the ID of the GVD to be used
gvdId: 'F04DC7C054CA48DA886A0B336BD61E37'
};
@cgillis-aras
cgillis-aras / labs_MethodTest.cs
Created October 11, 2019 15:34
Example of rolling up a property on the relationships to the parent
/*
* NOTE: This code is a sample to demonstrate how to rollup one level of a relationship.
* It is has not been fully tested and should not be used in a production environment as-is.
*/
/* Query for item and relationships happens above */
parentPart = parentPart.apply();
// Get the relationships from your item
Item partBoms = parentPart.getRelationships("Part BOM");
@cgillis-aras
cgillis-aras / OpenItemInEditMode.js
Created September 6, 2019 14:58
Sample JavaScript code to open an item in edit mode in Aras Innovator 12.0
/*
* We need to wait for the item's form to fully load before we switch the window to edit mode.
* Luckily, aras.uiShowItem returns a Promise that happens to resolve once the window loads. This
* means we can pass in a function using Promise.then(ourFunction) that will be called after the
* Promise resolves and the item window is loaded.
*/
aras.uiShowItem("Part", "64B2100E21B44980B42FB445951310BF").then(function()
{
// Look up the tab that was just loaded
var myItemWin = aras.uiFindWindowEx("64B2100E21B44980B42FB445951310BF");
@cgillis-aras
cgillis-aras / ApplyAsyncWithSpinner.js
Created July 30, 2019 17:44
Showing off how to use applyAsync to display a spinner while a long query is running in Aras Innovator.
var applyWithSpinner = async function(itm) {
aras.browserHelper.toggleSpinner(document, true);
var res = await itm.applyAsync();
aras.browserHelper.toggleSpinner(document, false);
return res;
}
// Create a query we know will take a while like querying for all Methods in the system
var longQueryItem = aras.IomInnovator.newItem("Method", "get");
var res = await applyWithSpinner(longQueryItem);
var scopeIds = {};
// Use a simple lookup table to get the value of the
var asilLookup = getAsilLookupTable();
// We want to style the ASIL value based on how important it is
var qmStyle = inArgs.factory.createCmfStyle();
qmStyle.textColor = "#000000";
qmStyle.textDecoration = "none";
qmStyle.fontWeight = "normal";