Skip to content

Instantly share code, notes, and snippets.

View EliJDonahue's full-sized avatar
😃
Working on exciting new projects for the Aras Community!

Eli J. Donahue EliJDonahue

😃
Working on exciting new projects for the Aras Community!
View GitHub Profile
@EliJDonahue
EliJDonahue / aras_labs_call_date_dialog.js
Created December 31, 2016 20:10
Demonstrates how to call a datepicker dialog via method code and perform some logic with the selected date.
// Prompt the user for the baseline date
var dateFormat = "yyyy-MM-dd HH:mm:ss";
var baseDate = new Date().format(dateFormat);
params = {
aras: top.aras,
format: dateFormat,
type: "Date",
date: baseDate
};
@EliJDonahue
EliJDonahue / aras_labs_style_non_current.js
Created January 1, 2017 23:04
Sets the background color of a non-current item's form
var itm = document.thisItem;
var inn = itm.getInnovator();
// if is_current property exists in the cache, use it
var isCurr = itm.getProperty("is_current","");
// else, retrieve is_current from the database
if(isCurr === ""){
itm = inn.getItemById(itm.getID());
isCurr = itm.getProperty("is_current", "");
@EliJDonahue
EliJDonahue / aras_labs_non_current_overlay.js
Created January 1, 2017 23:36
Displays a watermark image when the context item is not the current generation
var itm = document.thisItem;
var inn = itm.getInnovator();
// if is_current property exists in the cache, use it
var isCurr = itm.getProperty("is_current","");
// else, retrieve is_current from the database
if(isCurr === ""){
itm = inn.getItemById(itm.getID());
isCurr = itm.getProperty("is_current", "");
@EliJDonahue
EliJDonahue / forum_before_filter.xsl
Created January 8, 2017 19:20
Example of template before applying filter
<xsl:template match="Selector for EHT_Part Characteristics">
<p>
<xsl:value-of select="./eht_char_name"/>
<xsl:value-of select="./eht_char_val"/>
</p>
</xsl:template>
@EliJDonahue
EliJDonahue / forum_after_filter.xsl
Created January 8, 2017 19:21
Example of template after adding filter and new template
<xsl:template match="Selector for EHT_Part Charactheristics">
<p>
<xsl:value-of select="./eht_char_name"/>
<xsl:apply-templates select="./eht_char_val[text()='Mounting']"/>
</p>
</xsl:template>
<xsl:template match="eht_char_val">
<xsl:value-of select="."/>
</xsl:template>
@EliJDonahue
EliJDonahue / aras_labs_disabling_list_field.js
Last active February 15, 2017 19:48
Sample code demonstrating how to disable a list field on an Aras form
// get the form field "container"
var wrapper = getFieldByName("field_name");
// get the form field element
var l = wrapper.getElementsByTagName("select")[0];
// disabling/enabling field
if ( some_logic ) {
// disable list
l.disabled = true;
@EliJDonahue
EliJDonahue / aras_labs_power_bi_request.cs
Created April 25, 2017 16:02
Sample code for power BI blog
Innovator innovator = this.getInnovator();
string item = this.getProperty("item", "");
string name = this.getProperty("itemName", "");
Item result = innovator.applyMethod("PowerBI_GetToken", "");
string accessToken = result.getResult();
Item results = innovator.newItem();
@EliJDonahue
EliJDonahue / aras_labs_power_bi_field.html
Last active April 25, 2017 16:06
Sample code for an embedded Power BI report
<div id="pbiContainer"></div>
<script type="text/javascript">
// be sure to set the path for your Aras instance
require(["http://localhost/innovatorserver/Client/customer/powerbi/scripts/powerbi.js"],
function (pbi) {
var innovator = aras.newIOMInnovator();
var item = "report"; // The type of Power BI element you are querying
var itemName = "Product"; // The name of the element in Power BI you are querying
// Call the PowerBI_GetItem server method that will get an access token
@EliJDonahue
EliJDonahue / aras_labs_doc_data_contentgenerator.cs
Created June 15, 2017 17:36
Sample code for a content generator that displays a tech doc's metadata in an element on the tech doc
//MethodTemplateName=CSharp:Aras.TDF.ContentGenerator(Strict);
// get parent document
string doc_id = executionContext.DocumentId;
Innovator inn = this.Factory.InnovatorInstance;
Item thisDoc = inn.getItemById("tp_Block", doc_id);
if (!thisDoc.isError()) {
// get metadata we want to display from parent document
string num = thisDoc.getProperty("item_number","");
@EliJDonahue
EliJDonahue / aras_labs_doc_data_schema_element.xml
Created June 15, 2017 17:42
Sample code showing how to add the Doc-Data element for displaying tech doc metadata
<xs:element name="Standard-Doc">
<xs:complexType>
<xs:sequence>
<xs:element ref="Title"/>
<xs:element ref="Subtitle" minOccurs="0" maxOccurs="1"/>
<xs:element ref="Doc-Data" minOccurs="0" maxOccurs="1"/>
<xs:element ref="Section" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>