Skip to content

Instantly share code, notes, and snippets.

cgillis-aras

Block or report user

Report or block cgillis-aras

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View RD Compute ASIL.js
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";
@cgillis-aras
cgillis-aras / labs_ColorRelGridRow.js
Created May 8, 2019
Sample code to set the color of a relationship row based on property values.
View labs_ColorRelGridRow.js
// We want to style the rows of some of our relationships differently based on property value
// We're putting this in a Builder Method of a CommandBarSection so that our method is called each time the user
// clicks on a new tab.
var relationshipWeCareAbout = "159C6D88795B4A86864420863466F728"; // Put ID of relationship here
var currentRelationship = parent.relationships.currTabID;
// If we show any other relationship, don't do any additional processing
if (currentRelationship !== relationshipWeCareAbout)
{
return;
@cgillis-aras
cgillis-aras / SearchOnYesterday.cs
Last active May 3, 2019
Sample code for an onBeforeGet server event to replace the string "yesterday" in a date property with code that will search on yesterday's date.
View SearchOnYesterday.cs
Innovator inn = this.getInnovator();
string createdOn = this.getProperty("created_on", "");
if (createdOn == "yesterday")
{
DateTime yesterday = DateTime.Today.AddDays(-1);
DateTime eodYesterday = yesterday.AddHours(23).AddMinutes(59).AddSeconds(59);
this.setPropertyAttribute("created_on", "condition", "between");
this.setProperty("modified_on", String.Format("{0} and {1}",
yesterday.ToString("yyyy-MM-ddTHH:mm:ss"),
eodYesterday.ToString("yyyy-MM-ddTHH:mm:ss")));
@cgillis-aras
cgillis-aras / Test Open Classification.js
Last active Apr 24, 2019
Code to demonstrate opening the classification dialog in Aras Innovator 11.0
View Test Open Classification.js
// Trying to open the classification dialog programmatically
var ourItemTypeName = "Part"; // <-- Change this to your ItemType name
var ourItemType = top.aras.getItemTypeForClient(ourItemTypeName, "name");
var param = {
aras: top.aras,
isEditMode: true,
itemTypeName: ourItemTypeName,
class_structure: ourItemType.getProperty("class_structure"),
dialogType: 'classification',
@cgillis-aras
cgillis-aras / labs_GetRelatedOption.js
Last active Apr 22, 2019
Gets the related option value from the relationship grid. This is intended to be called from an OnInsertRow event.
View labs_GetRelatedOption.js
// Gets the related_option property from the relationships grid from an OnInsertRow event
var relOptionDropdown = this.toolbar.getItem("related_option");
// You can either perform your logic on the selected value or the selected index
/*
* Possible selected item values:
* "Create Related"
* "Pick Related"
* "No Related"
*/
@cgillis-aras
cgillis-aras / labs_SetOwnerOnInsertRow.js
Last active Apr 8, 2019
Sample code to update the value of a property's cell in a relationship grid.
View labs_SetOwnerOnInsertRow.js
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 / 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");
@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];
You can’t perform that action at this time.