Skip to content

Instantly share code, notes, and snippets.

cgillis-aras

View GitHub Profile
@cgillis-aras
cgillis-aras / Add Part and Attach to Parent.cs
Last active Mar 19, 2019
Example of a custom action in Aras Innovator
View Add Part and Attach to Parent.cs
Innovator inn = this.getInnovator();
Item partToAdd = this;
partToAdd.setAction("add");
string parentPartNumber = this.getAttribute("parent", "");
if (String.IsNullOrEmpty(parentPartNumber))
{
// If no parent is specified, just add the part like normal
return partToAdd.apply();
@cgillis-aras
cgillis-aras / setValueOnDelete.cs
Last active Feb 22, 2019
Example of setting a value of a related item in an onBeforeDelete event in Aras Innovator
View setValueOnDelete.cs
Innovator inn = this.getInnovator();
// Get the relationship with the related_id
Item rel = inn.newItem(this.getType(), "get");
rel.setID(this.getID());
rel.setAttribute("select","related_id");
rel = rel.apply();
// Make the change to the related item
Item related = inn.newItem("Part", "edit");
View labs_CreateGistFromSnippet.js
// Start by getting the login information for GitHub
var preference = aras.getPreferenceItem("Core_GlobalLayout");
var ghUsername = aras.getItemProperty(preference, "github_username", "");
var ghAccessToken = aras.getItemProperty(preference, "github_pat", "");
// Now get the selected text in the method
var formFrame = document.getElementById("instance");
var editorFrame = formFrame.contentDocument.getElementById("CodeEditor_iframe");
View labs_CreateGistFromMethod.js
var preference = aras.getPreferenceItem("Core_GlobalLayout");
var ghUsername = aras.getItemProperty(preference, "github_username", "");
var ghAccessToken = aras.getItemProperty(preference, "github_pat", "");
var methodCode = this.getProperty("method_code", "");
var methodType = this.getProperty("method_type", "");
var methodName = this.getProperty("name", "");
var methodBody = "<method_code>" + encodeXmlCharacters(methodCode) + "</method_code>";
@cgillis-aras
cgillis-aras / Open HTML File in Dialog.js
Created Feb 1, 2019
Sample code for displaying the content of an HTML file in a dialog within Aras Innovator
View Open HTML File in Dialog.js
// Set the arguments being passed to the dialog
var param = {
title: "Test HTML",
aras: top.aras,
dialogWidth: 500,
dialogHeight: 250,
content: 'test.html' // Put path to HTML file here
};
// Open the dialog
@cgillis-aras
cgillis-aras / Open HTML File in New Tab.js
Created Feb 1, 2019
Sample code for displaying the content of an HTML file form a new tab in Aras Innovator.
View Open HTML File in New Tab.js
// To open any window, it seems the aras object needs an item, so we're creating
// a completely blank item with a new ID that we'll use to lookup which window was just opened
var newItem = aras.IomInnovator.newItem("", "");
var newItemId = aras.generateNewGUID();
newItem.setID(newItemId);
aras.uiOpenEmptyWindowEx(newItem.node);
var newWindowName = aras.mainWindowName + "_" + newItemId;
var newWindow = aras.windowsByName[newWindowName];
@cgillis-aras
cgillis-aras / cui_printSelectedItemKeyedNames.js
Created Jan 16, 2019
Sample code for Aras Innovator to get the keyed_names of all selected items in the main grid.
View cui_printSelectedItemKeyedNames.js
var topWindow = aras.getMostTopWindowWithAras(window);
var workerFrame = topWindow.work;
var selectedIds = workerFrame.grid.getSelectedItemIds();
var itemTypeName = workerFrame.itemTypeName;
var selItems = aras.IomInnovator.newItem(itemTypeName, "get");
selItems.setAttribute("idlist", selectedIds.join(","));
selItems.setAttribute("select", "id,keyed_name");
selItems = selItems.apply();
@cgillis-aras
cgillis-aras / init_cui_on_multiselect.js
Created Jan 16, 2019
Sample code for Aras Innovator to enable/disable a CUI button based on the items selected in the grid
View init_cui_on_multiselect.js
if (inArgs.isReinit) {
var topWindow = aras.getMostTopWindowWithAras(window);
var workerFrame = topWindow.work;
if (workerFrame && workerFrame.grid && workerFrame.grid.getSelectedItemIds().length > 1)
{
return { "cui_disabled": false }; // enable the button
}
else
{
return { "cui_disabled": true }; // disable the button
@cgillis-aras
cgillis-aras / FilterItemField.js
Created Oct 8, 2018
Sample code for overriding the default server call that generates the type-ahead for an Item Field
View FilterItemField.js
// Get the field we want to populate dynamically
var item = getFieldComponentByName('owned_by_id');
// Override the default server call
item.component.request = function() {
var itemType = this.state.itemType;
var maxCount = this.state.maxItemsCount;
var label = this.state.label;
var req =
@cgillis-aras
cgillis-aras / DynamicallyPopulateDropdown.js
Last active Oct 9, 2018
Sample code for an onFormPopulated event that dynamically populates an empty dropdown field
View DynamicallyPopulateDropdown.js
// Get the field we want to populate dynamically
var dropdown = getFieldComponentByName('authoring_tool');
/* Construct a filtered list that contains only Microsoft Office authoring tools */
var listItm = aras.IomInnovator.newItem("List", "get");
listItm.setAttribute("select", "id");
listItm.setProperty("name", "Authoring Tools");
var itms = aras.IomInnovator.newItem("Value", "get");
itms.setAttribute("select", "value,label");
You can’t perform that action at this time.