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 / StandardSearchFilter.js
Created May 31, 2018 19:52
Example of how to use a standard search filter from an onSearchDialog event in Aras Innovator
// Example of the standard way to set a Filter in an onSearchDialog event
var Filter = {};
Filter["name"] = { filterValue: "%Admin", isFilterFixed: false };
Filter["is_alias"] = { filterValue: "1", isFilterFixed: true };
return Filter;
@cgillis-aras
cgillis-aras / IdlistSearchFilter.js
Created May 31, 2018 20:10
Example of how to filter by a list of IDs in an onSearchDialog event in Aras Innovator
var inn = this.getInnovator();
var ident = inn.newItem("Identity", "get");
var or = ident.newOR();
// Search for our Admin Identities...
var and1 = or.newAND();
and1.setProperty("name", "%Admin");
and1.setPropertyAttribute("name", "condition", "like");
and1.setProperty("is_alias", "1");
@cgillis-aras
cgillis-aras / DisableDateField.js
Created June 29, 2018 14:51
Sample code demonstrating how to disable a date field in Aras Innovator
var input = getFieldByName("effective_date");
input.getElementsByTagName("input")[0].disabled = true;
input.getElementsByTagName("input")[1].disabled = true;
input.getElementsByTagName("input")[1].src = "../images/calendar-disabled.svg";
@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 / FilterItemField.js
Created October 8, 2018 21:19
Sample code for overriding the default server call that generates the type-ahead for an Item Field
// 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 / labs_dropdown_init.js
Last active November 19, 2021 19:07
Sample code for populating a CUI dropdown in Aras Innovator with a list of all of the generations of the current item
// This is to account for the case where this dropdown accidentally gets added to a non-versionable item
const isVersionableItemType = options.itemType['is_versionable'] === '1';
if (!isVersionableItemType) {
return { hidden: true };
}
/* Query for the IDs of all generations */
// Need the config ID to get all generations
// TODO: We could skip this step if we can get the config_id from the window, but it's not readily available
var configIdQuery = aras.IomInnovator.newItem(options.itemTypeName, "get");
@cgillis-aras
cgillis-aras / labs_open_version_button.js
Created November 19, 2021 15:47
Sample code for Aras Innovator that demonstrates how to open an older version of an item using a CUI button
var generationDropdown = control.data.get("labs.part.ivcb.version_selector.dropdown");
var selectedId = generationDropdown.value;
var selItemQuery = aras.IomInnovator.newItem(options.itemTypeName, "get");
selItemQuery.setID(selectedId);
selItemQuery = selItemQuery.apply();
aras.uiShowItemEx(selItemQuery.node);
@cgillis-aras
cgillis-aras / labs_newitemwithclass_execute.js
Created October 21, 2021 12:59
Sample code for Aras Innovator to open a classification dialog before opening a new item of that classification.
const itemType = options.itemType;
// Open up a classification dialog
var param = {
aras: aras,
isEditMode: true,
itemTypeName: itemType.name,
class_structure: itemType.class_structure,
dialogType: 'classification',
selectLeafOnly: true,
@cgillis-aras
cgillis-aras / labs_SetOwnerOnInsertRow.js
Last active September 23, 2021 19:57
Sample code to update the value of a property's cell in a relationship grid.
var set_property = setRelatedItemProperty(relationshipID, "owned_by_id", "DBA5D86402BF43D5976854B8B48FCDD1");
// At this point the value is set on the item in the dom, but it does not seem to appear in the grid
// By debugging into this function, the item also does not seem to be added to the grid at this point, so we'll need to handle this logic in a timeout
setTimeout(function(relID) {
var gridApp = this.gridApplet;
var columnName = gridApp.GetPropertyColumnName("owned_by_id");
gridApp.SetCellValue(relID, gridApp.GetTrueColumnIndex(columnName), "Innovator Admin"); // <-- This should be the keyed_name of the item
}, 50, relationshipID);
@cgillis-aras
cgillis-aras / labs_GetRelationshipTabIdFromItemForm.js
Created September 10, 2021 04:40
Sample code to get the title of the relationships tab
var relationshipTabInfo = parent.relationships.relTabbar;
var currentRelationshipTabId = relationshipTabInfo.GetSelectedTab();
var tabLabel = relationshipTabInfo.GetTabLabel(currentRelationshipTabId);