Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Gillis cgillis-aras

View GitHub Profile
@cgillis-aras
cgillis-aras / labs_GenericCheckClaimedBy.cs
Created Jan 12, 2021
Sample code for a generic version of an action that will get the name of the User who has claimed any ItemType
View labs_GenericCheckClaimedBy.cs
Innovator inn = this.getInnovator();
// Check to see if this item is claimed at all
if (this.isLocked() == 0)
{
return inn.newResult("No one");
}
// Query to make sure that we have the locked_by_id property
string selectedType = this.getType();
@cgillis-aras
cgillis-aras / labs_HardcodedCheckClaimedBy.cs
Last active Jan 12, 2021
Sample code for a hard-coded version of an action that will get the name of the User who has claimed a selected Part
View labs_HardcodedCheckClaimedBy.cs
Innovator inn = this.getInnovator();
// Check to see if this item is claimed at all
if (this.isLocked() == 0)
{
return inn.newResult("No one");
}
// Query to make sure that we have the locked_by_id property
Item part = inn.newItem("Part", "get");
@cgillis-aras
cgillis-aras / ItemPropertyShorthands.cs
Created Jan 11, 2021
Examples of shorthand functions for adding items to a query in Aras Innovator.
View ItemPropertyShorthands.cs
Innovator inn = this.getInnovator();
Item part = inn.newItem("Part", "get");
// Add a Part BOM relationship to this query
Item partBom = inn.newItem("Part BOM", "get");
part.addRelationship(partBom);
// Shorthand equivalent
Item partBom = part.createRelationship("Part BOM", "get");
// Add an Item property to this query
@cgillis-aras
cgillis-aras / AttributeShorthandFunctions.cs
Created Jan 11, 2021
Examples of the specific attribute shorthand functions in Aras Innovator.
View AttributeShorthandFunctions.cs
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 Dec 16, 2020
An example of a method in Aras Innovator that makes a get request while using the returnMode attribute with a value of countOnly
View RequestWithCountOnly.cs
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 Dec 16, 2020
An example of a method inside of Aras Innovator that adds an item while using the doGetItem attribute
View RequestWithDoGetItem.cs
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 Nov 8, 2019
Copy of the cui_reinit_calc_tearoff_states JavaScript method in Aras Innovator
View cui_reinit_calc_tearoff_states.js
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 Nov 8, 2019
Copy of the cui_reinit_calc_tearoff_states JavaScript method in Aras Innovator
View cui_reinit_calc_tearoff_states.js
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 Nov 5, 2019 — forked from EliJDonahue/araslabs_ShowMyGraph.js
Sample method code for opening a specific graph view
View araslabs_ShowMyGraph.js
// 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 Oct 11, 2019
Example of rolling up a property on the relationships to the parent
View labs_MethodTest.cs
/*
* 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");