function GMComapnyFilterSuppliers() {
var companies = this.newItem(inArgs.itemTypeName, "get");
companies = companies.apply();
var totalComapnyCount = companies.getItemCount();
var innovator = new top.Innovator();
var idsToExclude = new Array();
var ecr = innovator.getItemById("gm_work order", inArgs.itemSelectedID);
ecr.fetchRelationships("gm_Work Order gm_Company");
var existingSuppliers = ecr.getRelationships("gm_Work Order gm_Company");
var supplierCount = existingSuppliers.getItemCount();
for (var i = 0; i < supplierCount; i++) {
var relatedItemRelationship = existingSuppliers.getItemByIndex(i);
var company = relatedItemRelationship.getRelatedItem();
idsToExclude.push(company.getID());
var idArray = new Array();
for (var i = 0; i < totalComapnyCount; i++) {
var company = companies.getItemByIndex(i);
var companyName = company.getProperty("_company_name");
var companyId = company.getID();
if (!companyName.toLowerCase().startsWith("gm") && idsToExclude.indexOf(companyId) == -1) {
idArray[j++] = companyId;
if (idArray.length === 0) {
idArray.push(inArgs.itemSelectedID);
var idlist=idArray.join(",");
inArgs.QryItem.item.setAttribute("idlist", idlist);
function gm_Query_PPAT_onSearchClick() {
PPATResultItemType: "gm_Query PPAT Result",
SearchMethodName: "gm_Query PPAT onSearch",
WorkOrder: "gm_Work Order",
WorkOrderId: "_work_order",
EcrNumber: "item_number",
var topWnd = window.TopWindowHelper.getMostTopWindowWithAras();
var innovator = aras.newIOMInnovator();
var removeAllRelationship = function (item, relationshipName) {
var allRels = item.getRelationships(relationshipName);
var relCount = allRels.getItemCount();
for (var i = 0; i < relCount; i++) {
item.removeRelationship(allRels.getItemByIndex(i));
var addRelationships = function (item, relationships) {
var relCount = relationships.getItemCount();
for (var i = 0; i < relCount; i++) {
item.addRelationship(relationships.getItemByIndex(i));
var getEcr = function () {
var workOrderId = document.thisItem.getProperty(constants.WorkOrderId, "");
var workOrderWindow = aras.uiFindWindowEx(workOrderId);
if (workOrderWindow.thisItem) {
return workOrderWindow.thisItem;
return innovator.getItemById(constants.WorkOrder, workOrderId);
var onSearch = function (queryItem, tWnd, spinnerAsync) {
aras.browserHelper.toggleSpinner(tWnd.document, true);
return setTimeout(function () {
onSearch(queryItem, tWnd, true);
var methodItem = queryItem.clone();
methodItem.setAttribute(constants.Type, constants.Method);
methodItem.setAction(constants.SearchMethodName);
var result = methodItem.apply();
removeAllRelationship(queryItem, constants.PPATResultItemType);
ecrNumber = getEcr().getProperty(constants.EcrNumber, "");
throw "Query for ECR " + ecrNumber + ": " + result.getErrorString();
if (result.getRelationships(constants.PPATResultItemType).getItemCount() === 0) {
removeAllRelationship(queryItem, constants.PPATResultItemType);
ecrNumber = getEcr().getProperty(constants.EcrNumber, "");
return top.aras.AlertWarning("Query for ECR " + ecrNumber + ": No results to display.");
removeAllRelationship(queryItem, constants.PPATResultItemType);
addRelationships(queryItem, result.getRelationships(constants.PPATResultItemType));
return top.aras.AlertError(ex);
aras.browserHelper.toggleSpinner(topWnd.document, false);
onSearch(document.thisItem, topWnd, false);
function gm_PPAT_Dialog_onSearchDialog() {
var workOrderId = inArgs.itemSelectedID;
workOrderId = parent.thisItem.getID();
var Filter = new Object();
Filter["_work_order_id"] = { filterValue: workOrderId, isFilterFixed: true };
function gm_ARAS_Context_Utilities() {
top[document.thisItem.getID() + 'gmArasContextUtilityNS'] = gmArasContextUtilityNS;
var gmArasContextUtilityNS = gmArasContextUtilityNS || function () {
var getContextForId = function (windowId) {
var currentWindow = aras.uiFindWindowEx(windowId);
var currentContext = currentWindow.instance;
if (currentContext.contentWindow) {
currentContext = currentContext.contentWindow;
var getParentContext = function (isGrid, parent) {
windowId = parent.thisItem.getID();
windowId = parent.thisItem.getProperty("source_id");
return getContextForId(windowId);
var updateGridProperty = function (currentContext, gridApplet, relationshipID, propertyName, value, isItem) {
currentContext.gmARASGridUtilitiesNS.setCellItemValue(gridApplet, relationshipID, propertyName, value);
currentContext.gmARASGridUtilitiesNS.setCellValue(gridApplet, relationshipID, propertyName, value);
var updateProperty = function (parentContext, gridApplet, itemIdToUpdate, propertyName, value, isItem, tabName) {
var currentFormContext = getContextForId(itemIdToUpdate);
currentFormContext.handleItemChange(propertyName, value.getID());
var currentGrid = parentContext.gmARASGridUtilitiesNS.getGridForTabName(tabName);
parentContext.gmARASGridUtilitiesNS.setCellItemValue(currentGrid, itemIdToUpdate, propertyName, value);
currentFormContext.handleItemChange(propertyName, value || "");
updateGridProperty(parentContext, gridApplet, itemIdToUpdate, propertyName, value, isItem);
var itemInEditableState = function (currentRow, relationshipID) {
var action = currentRow.getAction();
if (action.toLowerCase() === constants.Actions.Add) {
var state = currentRow.getProperty(constants.PropertyNames.State, "");
var item = aras.newIOMInnovator().newItem(currentRow.getType(), constants.Actions.Get);
item.setID(relationshipID);
item.setAttribute(constants.Attributes.Select, constants.PropertyNames.State);
state = item.getProperty(constants.PropertyNames.State, "");
if (state.toLowerCase() !== "edit") {
var currentUserHasUpdateAccess = function (workOrderId, itemType) {
var hasUpdateAccess = aras.newIOMInnovator().applyMethod("gm_ValidateUserRoleForFinishDate", "<work_order_id>" + workOrderId + "</work_order_id>"
+ "<rel_name>" + itemType + "</rel_name>").getResult();
return hasUpdateAccess === "true";
var isEditableLifecycleState = function (parentContext, relationshipID) {
if (!parentContext.document.isEditMode) {
if (document.isEditMode !== undefined && !document.isEditMode) {
var parentItem = parentContext.parent.thisItem;
var currentRow = parentItem.getItemsByXPath("//Relationships/Item[@id='" + relationshipID + "']");
currentRow = currentRow.getItemByIndex(0);
if (!itemInEditableState(currentRow, relationshipID)) {
if (parentItem.getType().toLowerCase() === "gm_work order") {
return currentUserHasUpdateAccess(parentContext.parent.thisItem.getId(), currentRow.getType());
var getPropertyKeyedName = function (item, propertyName) {
var propertyItem = item.getPropertyItem(propertyName);
keyedName = propertyItem.getAttribute(constants.Attributes.KeyedName, "");
keyedName = propertyItem.getProperty(constants.Attributes.KeyedName, "");
keyedName = propertyItem.getPropertyAttribute("id", constants.Attributes.KeyedName, "");
keyedName = item.getPropertyAttribute(propertyName, constants.Attributes.KeyedName, "");
getContextForId: getContextForId,
getParentContext: getParentContext,
updateGridProperty: updateGridProperty,
updateProperty: updateProperty,
isEditableLifecycleState: isEditableLifecycleState,
getPropertyKeyedName: getPropertyKeyedName
function end_of_method() {
function gm_ARAS_Dialog_Utilities() {
top.arasModalDialogForFormNS = arasModalDialogForFormNS;
var arasModalDialogForFormNS = arasModalDialogForFormNS || function () {
DefaultPopup: "DefaultPopup",
DialogHtmlName: "ShowFormAsADialog.html",
var getForm = function (formName) {
var form = top.Innovator().newItem(CONSTANTS.ItemTypeNames.Form, CONSTANTS.Attributes.Get);
form.setAttribute(CONSTANTS.Attributes.Select, "id,width,height");
form.setProperty(CONSTANTS.PropertyNames.Name, formName);
var createOptionsForForm = function (form) {
var height = form.getProperty(CONSTANTS.PropertyNames.Height, "600");
var width = form.getProperty(CONSTANTS.PropertyNames.Width, "800");
var createParameters = function (form, dialogTitle, item) {
var param = new Object();
param.title = dialogTitle;
param.formId = form.getItemByIndex(0).getID();
var show = function (param, options) {
var wnd = aras.getMainWindow();
wnd = wnd === top ? wnd.main : top;
aras.modalDialogHelper.show(CONSTANTS.DefaultPopup, wnd, param, options, CONSTANTS.DialogHtmlName);
var hideDialog = function () {
var showDialog = function (formName, dialogTitle, paramItem) {
var form = getForm(formName);
return top.aras.AlertError(form.getErrorString());
var options = createOptionsForForm(form);
var param = createParameters(form, dialogTitle, paramItem);
function end_of_method() {
function gm_ARAS_Itemtype_Utilities() {
top.gmARASEventUtilitiesNS = gmARASEventUtilitiesNS;
var gmARASEventUtilitiesNS = gmARASEventUtilitiesNS || function () {
var currentContext = null;
var innovator = aras.newIOMInnovator();
var getItemUsingKeyedName = function (propertyName, keyedName, itemType) {
var propertyItem = currentContext.getPropertyItem(propertyName);
if (!propertyItem || propertyItem.getProperty("keyed_name") !== keyedName) {
propertyItem = aras.newIOMInnovator().newItem(itemType, "get");
propertyItem.setProperty("keyed_name", keyedName);
propertyItem = propertyItem.apply();
if (propertyItem.isError()) {
if (propertyItem.getErrorCode() === "0") {
return aras.newIOMInnovator().newItem(itemType, "get");
throw propertyItem.getErrorDetail();
if (propertyItem.getItemCount() > 1) {
propertyItem = propertyItem.getItemByIndex(0);
currentContext.setPropertyItem(propertyName, propertyItem);
var getPropertyAfterEvent = function (context, propertyName, event, propertyItemType) {
currentContext = context;
if (!event || event.srcElement.name !== propertyName) {
return currentContext.getProperty(propertyName);
if (event.srcElement.value) {
return getItemUsingKeyedName(propertyName, event.srcElement.value, propertyItemType).getProperty("id");
return event.srcElement.value;
return event.srcElement.value;
getPropertyAfterEvent: getPropertyAfterEvent
function end_of_method() {
function gm_UI_Utilities() {
top.gmARASGridUtilitiesNS = gmARASGridUtilitiesNS;
var gmARASGridUtilitiesNS = gmARASGridUtilitiesNS || function () {
var parentContext = parent;
var innovator = aras.newIOMInnovator();
var getColumnIndex = function (grid, propertyName) {
return grid.grid_Experimental.order.indexOf(grid.GetColumnIndex(propertyName + "_D"));
var setParentContext = function (currentParentContext) {
if (currentParentContext) {
parentContext = currentParentContext;
var setCellValue = function (grid, relationshipID, propertyName, value) {
if (value === undefined || value === null) {
grid.cells(relationshipID, getColumnIndex(grid, propertyName)).setValue(value);
var currentItem = parentContext.thisItem.getItemsByXPath("//Item[@id='" + relationshipID + "']");
if (currentItem.nodeList && currentItem.nodeList.length > 1) {
currentItem = currentItem.getItemByIndex(0);
currentItem.setProperty(propertyName, value);
currentItem.RemovePropertyAttribute(propertyName, "keyed_name");
currentItem.RemovePropertyAttribute(propertyName, "type");
if (!currentItem.getAction()) {
currentItem.setAction("update");
if (currentItem.getAttribute("isDirty") !== "1") {
currentItem.setAttribute("isDirty", "1");
var setCellValueButNotCache = function (grid, relationshipID, propertyName, value) {
if (value === undefined || value === null) {
grid.cells(relationshipID, getColumnIndex(grid, propertyName)).setValue(value);
var setCellItemValue = function (grid, relationshipID, propertyName, item) {
if (item === undefined || item === null || item === "") {
setCellValue(grid, relationshipID, propertyName, item);
var keyedName = item.getProperty("keyed_name", "");
keyedName = item.getAttribute("keyed_name");
var dbItem = innovator.getItemById(item.getType(), item.getID());
keyedName = dbItem.getProperty("keyed_name", "");
keyedName = relationshipID;
grid.cells(relationshipID, getColumnIndex(grid, propertyName)).setValue(keyedName);
var currentItem = parentContext.thisItem.getItemsByXPath("//Item[@id='" + relationshipID + "']");
if (currentItem.nodeList && currentItem.nodeList.length > 1) {
currentItem = currentItem.getItemByIndex(0);
item.setAttribute("keyed_name", keyedName);
item.setPropertyAttribute(propertyName, "keyed_name", keyedName);
if (item.node.innerHTML) {
item.node.innerHTML = '';
currentItem.setProperty(propertyName, item.getID());
currentItem.setPropertyItem(propertyName, item);
currentItem.setPropertyAttribute(propertyName, "keyed_name", keyedName);
if (!currentItem.getAction()) {
currentItem.setAction("update");
if (currentItem.getAttribute("isDirty") !== "1") {
currentItem.setAttribute("isDirty", "1");
var getGridForTabName = function (tabName, parentScope) {
parentScope = parentScope || parentContext;
if (!parentScope.relationships ||
!parentScope.relationships.relTabbarReady ||
parentScope.relationships.relTabbar.GetTabOrder("|") === "") {
getGridForTabName(tabName, parentScope);
var tabbar = parentScope.relationships.relTabbar;
var tabID = tabbar.GetTabId(tabName);
var tabIFrame = parentScope.relationships.iframesCollection[tabID];
if (tabIFrame && tabIFrame.contentWindow) {
return tabIFrame.contentWindow.grid;
var getGridForTabNameAndWindowId = function (windowId, tabName) {
if (!windowId || !tabName) {
var itemWindow = aras.uiFindWindowEx(windowId);
var itemRelTabId = itemWindow.relationships.relTabbar.GetTabId(tabName);
var itemRelTab = itemWindow.relationships.iframesCollection[itemRelTabId];
if (itemRelTab && itemRelTab.contentWindow) {
return itemRelTab.contentWindow.grid;
var getCellValueForRowIndex = function (grid, rowIndex, propertyName) {
if (!grid || rowIndex === undefined || rowIndex === null || !propertyName) {
var rowId = grid.getRowId(rowIndex);
var columnIndex = getColumnIndex(grid, propertyName);
return grid.GetCellValue(rowId, columnIndex);
var getCellValueForRowId = function (grid, rowId, propertyName) {
if (!grid || !rowId || !propertyName) {
var columnIndex = getColumnIndex(grid, propertyName);
return grid.GetCellValue(rowId, columnIndex);
var getValueListForPropertyName = function (grid, propertyName, distinct) {
if (!grid || !propertyName) {
var rowCount = grid.GetRowCount();
for (var i = 0; i < rowCount; i++) {
var value = getCellValueForRowIndex(grid, i, propertyName);
if (!distinct || allValues.indexOf(value) === -1) {
var getValuesForPropertyNameContainingSubstring = function (grid, propertyName, substring, distinct) {
if (!grid || !substring || !propertyName) {
var upperCaseValues = [];
var rowCount = grid.GetRowCount();
for (var i = 0; i < rowCount; i++) {
var value = getCellValueForRowIndex(grid, i, propertyName);
if (value && value.toUpperCase().indexOf(substring.toUpperCase()) !== -1) {
if (!distinct || upperCaseValues.indexOf(value.toUpperCase()) === -1) {
upperCaseValues.push(value.toUpperCase());
var getPropertyValuesForGivenAction = function (grid, propertyName, action, distinct) {
if (!grid || !propertyName || !action) {
var rowCount = grid.GetRowCount();
for (var i = 0; i < rowCount; i++) {
var rowId = grid.getRowId(i);
var currentItem = parentContext.thisItem.getItemsByXPath("//Item[@id='" + rowId + "']");
var currentRowAction = currentItem.getAction();
if (currentRowAction && currentRowAction.toUpperCase() === action.toUpperCase()) {
var value = propertyName.toUpperCase() === "ID" ? rowId : getCellValueForRowIndex(grid, i, propertyName);
if (!distinct || allValues.indexOf(value) === -1) {
var setListValueInCell = function (grid, rowId, propertyName, labels, values) {
var columnIndex = getColumnIndex(grid, propertyName);
var cell = grid.cells(rowId, columnIndex);
cell.setCombo_Experimental(labels, values, "^");
var getRelationshipContentWindow = function (tabName, parentScope) {
parentScope = parentScope || parentContext;
if (!parentScope.relationships ||
!parentScope.relationships.relTabbarReady ||
parentScope.relationships.relTabbar.GetTabOrder("|") === "") {
getRelationshipContentWindow(tabName, parentScope);
var tabbar = parentScope.relationships.relTabbar;
var tabID = tabbar.GetTabId(tabName);
var tabIFrame = parentScope.relationships.iframesCollection[tabID];
if (tabIFrame && tabIFrame.contentWindow) {
return tabIFrame.contentWindow;
var fireCellEvent = function (tabName, parentScope, rowId, propertyName, eventName) {
var contentWindow = getRelationshipContentWindow(tabName, parentScope);
var grid = contentWindow.grid;
var columnIndex = getColumnIndex(grid, propertyName);
contentWindow.handleCellEvent(eventName, rowId, getColumnIndex(grid, propertyName));
var setColumnVisibility = function (grid, propertyName, isVisible, columnWidth) {
var propertyIndex = getColumnIndex(grid, propertyName);
grid.SetColumnVisible(propertyIndex, isVisible, columnWidth);
var updateColumnWidth = function (grid, propertyName, columnWidth) {
var propertyIndex = getColumnIndex(grid, propertyName);
grid.SetColumnVisible(propertyIndex, false, columnWidth);
grid.SetColumnVisible(propertyIndex, true, columnWidth);
setParentContext: setParentContext,
setCellValue: setCellValue,
setCellItemValue: setCellItemValue,
setCellValueButNotCache: setCellValueButNotCache,
getColumnIndex: getColumnIndex,
getGridForTabName: getGridForTabName,
getGridForTabNameAndWindowId: getGridForTabNameAndWindowId,
getCellValueForRowIndex: getCellValueForRowIndex,
getCellValueForRowId: getCellValueForRowId,
getValueListForPropertyName: getValueListForPropertyName,
getValuesForPropertyNameContainingSubstring: getValuesForPropertyNameContainingSubstring,
getNPNSequencesForPropertyName: getNPNSequencesForPropertyName,
getPropertyValuesForGivenAction: getPropertyValuesForGivenAction,
getRelationshipContentWindow: getRelationshipContentWindow,
fireCellEvent: fireCellEvent,
setColumnVisibility: setColumnVisibility,
updateColumnWidth: updateColumnWidth
function end_of_method() {
function gm_File_Revision_Hide_Controls() {
var gmARASMenuUtilitiesNS = gmARASMenuUtilitiesNS || function () {
var maxSetTimeRepeat = 100;
var contentWindow = null;
var hideButtonsForIds = function (buttonsIdsToHide) {
for (var i = 0; i < buttonsIdsToHide.length; i++) {
contentWindow.toolbar.hideItem(buttonsIdsToHide[i]);
var hideButtonsForNames = function (buttonsNamesToHide) {
for (var i = 0; i < buttonsNamesToHide.length; i++) {
var buttonId = contentWindow.toolbar.GetButtonId(buttonsNamesToHide[i]);
if (buttonId != undefined) {
contentWindow.toolbar.hideItem(buttonId);
var showButtonsForIds = function (buttonsIdsToHide) {
for (var i = 0; i < buttonsIdsToHide.length; i++) {
contentWindow.toolbar.showItem(buttonsIdsToHide[i]);
var showButtonsForNames = function (buttonsNamesToHide) {
for (var i = 0; i < buttonsNamesToHide.length; i++) {
var buttonId = contentWindow.GetButtonId(buttonsNamesToHide[i]);
if (buttonId != undefined) {
contentWindow.showItem(buttonId);
var showHideMenuButtons = function (context, tabName, buttonIdsArray, currentIteration, isIds, hide) {
if (!context || !tabName || !buttonIdsArray || buttonIdsArray.length === 0 || currentIteration > maxSetTimeRepeat) {
if (!context.relationships || !context.relationships.relTabbarReady || context.relationships.relTabbar.GetTabOrder("|") === "") {
showHideMenuButtons(context, tabName, buttonIdsArray, currentIteration, isIds, hide);
var tabbar = context.relationships.relTabbar;
var tabID = tabbar.GetTabId(tabName);
if (!context.relationships.iframesCollection[tabID].contentWindow.toolbar.hideItem) {
showHideMenuButtons(context, tabName, buttonIdsArray, currentIteration, isIds, hide);
contentWindow = context.relationships.iframesCollection[tabID].contentWindow;
hideButtonsForIds(buttonIdsArray);
hideButtonsForNames(buttonIdsArray);
showButtonsForIds(buttonIdsArray);
showButtonsForNames(buttonIdsArray);
var showMenuButtons = function (context, tabName, buttonIdsArray, currentIteration, isIds) {
showHideMenuButtons(context, tabName, buttonIdsArray, currentIteration, isIds, false);
var hideMenuButtons = function (context, tabName, buttonIdsArray, currentIteration, isIds) {
showHideMenuButtons(context, tabName, buttonIdsArray, currentIteration, isIds, true);
var setMaxIteration = function (maxIteration) {
maxSetTimeRepeat = maxIteration;
setMaxIterationNumber: setMaxIteration,
hideMenuButtons: hideMenuButtons,
showMenuButtons: showMenuButtons
function end_of_method() {