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 / 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");
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 15:29
Sample code to set the color of a relationship row based on property values.
// 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 14:07
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.
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 April 24, 2019 14:15
Code to demonstrate opening the classification dialog in Aras Innovator 11.0
// 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 April 22, 2019 13:44
Gets the related option value from the relationship grid. This is intended to be called from an OnInsertRow event.
// 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 / Add Part and Attach to Parent.cs
Last active March 19, 2019 20:11
Example of a custom action in Aras Innovator
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();