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 / init_cui_on_multiselect.js
Created January 16, 2019 15:56
Sample code for Aras Innovator to enable/disable a CUI button based on the items selected in the grid
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 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 / DynamicallyPopulateDropdown.js
Last active October 9, 2018 13:40
Sample code for an onFormPopulated event that dynamically populates an empty dropdown field
// 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");
@cgillis-aras
cgillis-aras / ClassDefinitionInInnovatorMethod.vb
Created October 1, 2018 15:26
Shows how to define a class or function within an Innovator Method
' Primary code that will execute when this method is called
Dim test as New Foo
Return Me.getInnovator().newResult(test.Food())
End Function
' Our class definition
Public Class Foo
Function Food() as String
Return "Cheese"
End Function
@cgillis-aras
cgillis-aras / docOnBeforeAdd.cs
Created August 21, 2018 20:01
Example code that will successfully add a sibling Document from an onBeforeAdd on the Document ItemType using fake proeprties
Innovator inn = this.getInnovator();
if (this.getProperty("is_sibling") == "1") {
return this;
} else {
Item newDoc = inn.newItem("Document", "add");
newDoc.setProperty("item_number", this.getProperty("item_number") + " - Design");
newDoc.setProperty("name", this.getProperty("name") + "'s Sibling");
newDoc.setProperty("is_sibling", "1");
newDoc = newDoc.apply();
}
@cgillis-aras
cgillis-aras / docOnBeforeAdd-infiniteLoop.cs
Last active August 21, 2018 20:00
Example code that will cause an infinite loop when trying to create a Document during an onBeforeAdd event of the Document ItemType
// WARNING: This code will cause an infinite loop when run from an onBeforeAdd event on the Document ItemType.
// It is meant to serve as an example only.
Innovator inn = this.getInnovator();
Item newDoc = inn.newItem("Document", "add");
newDoc.setProperty("item_number", this.getProperty("item_number") + " - Design");
newDoc.setProperty("name", this.getProperty("name") + "'s Sibling");
newDoc = newDoc.apply();
return this;
@cgillis-aras
cgillis-aras / addPartWithFakeProperty.xml
Last active August 21, 2018 20:19
Example of adding a Part with a fake property that does not exist on the ItemType
<AML>
<Item type="Part" action="add">
<item_number>PRT-0002</item_number>
<name>My New Part</name>
<fake_property>Test</fake_property>
</Item>
</AML>
@cgillis-aras
cgillis-aras / addPart.xml
Created August 21, 2018 19:53
Simple example of adding a Part through AML
<AML>
<Item type="Part" action="add">
<item_number>PRT-0001</item_number>
<name>My New Part</name>
</Item>
</AML>
@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 / DisableItemField.js
Created June 29, 2018 14:29
Sample code demonstrating how to disable an item field in Aras Innovator
var input = getFieldByName("owned_by_id");
setTimeout(function() {
input.getElementsByTagName("input")[0].disabled = true;
input.getElementsByTagName("button")[0].disabled = true;
}, 100);