public void idoInsert() { LogMessage("idoInsert"); UpdateCollectionRequestData insert = new UpdateCollectionRequestData(ido); IDOUpdateItem itm = new IDOUpdateItem(UpdateAction.Insert); //ONE PROPERTY if (!properties.Contains(",")) { itm.Properties.Add(properties, values); insert.Items.Add(itm); } else { string[] propertyArray = properties.Split(','); string[] valueArray = values.Split(','); for (int i = 0; i < propertyArray.Length; i++) { itm.Properties.Add(propertyArray[i], valueArray[i]); insert.Items.Add(itm); } } stopwatch.Start(); IDOClient.UpdateCollection(insert); stopwatch.Stop(); stopwatch.Reset(); }
/// <summary> /// Enable / Disable the Quick Add Product Menu /// -- Enable: if BOE is disabled -- /// -- Disable: if BOE is enabled -- /// </summary> public void EnableDisableProductMenu() { var integrationCollection = IDOClient.LoadCollection("CRMIntegration", "Enabled", "Name = 'Back Office Extension'", string.Empty, 1); int enabled = integrationCollection[0, "Enabled"].GetValue <int>() == 1 ? 0 : 1; string filter = string.Format("Action = '{0}'", "CRMQuickAddProduct"); LoadCollectionResponseData loadResponse = IDOClient.LoadCollection("CRMMenus", "Enabled", filter, string.Empty, 1); var updateReq = new UpdateCollectionRequestData() { IDOName = "CRMMenus", RefreshAfterUpdate = true }; foreach (var current in loadResponse.Items) { var updateItem = new IDOUpdateItem() { ItemID = current.ItemID, Action = UpdateAction.Update }; updateItem.Properties.Add("Enabled", enabled); updateReq.Items.Add(updateItem); } IDOClient.UpdateCollection(updateReq); }
public void AddAccountPlanningCycle() { UpdateCollectionRequestData req = new UpdateCollectionRequestData(); req.IDOName = "CRMPlanningCycleAssociations"; req.RefreshAfterUpdate = true; var accountID = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("ID"); var count = ThisForm.ModalChildForm.PrimaryIDOCollection.GetNumEntries(); var accountPlanningCycle = string.Empty; for (var curIndex = 0; curIndex < count; curIndex++) { if (ThisForm.ModalChildForm.PrimaryIDOCollection.GetObjectProperty("CRMRecordSelected", curIndex) == "1") { IDOUpdateItem newItem; string planningCycleID = ThisForm.ModalChildForm.PrimaryIDOCollection.GetObjectProperty("ID", curIndex); if (planningCycleID == null) { return; } if (!IsDuplicateAccountPlanningCycleRecord(accountID, planningCycleID)) { newItem = MapAccountPlanningCycle(accountID, planningCycleID); req.Items.Add(newItem); } } } IDOClient.UpdateCollection(req); ThisForm.PrimaryIDOCollection.RefreshKeepCurIndex(); return; }
private void AddAccountCampaign() { UpdateCollectionRequestData req = new UpdateCollectionRequestData(); req.IDOName = "CRMCampaignAccount"; req.RefreshAfterUpdate = true; string primaryID = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("ID"); int count = ThisForm.ModalChildForm.PrimaryIDOCollection.GetNumEntries(); for (var curIndex = 0; curIndex < count; curIndex++) { if (ThisForm.ModalChildForm.PrimaryIDOCollection.GetObjectProperty("CRMRecordSelected", curIndex) == "1") { IDOUpdateItem newItem; var childID = ThisForm.ModalChildForm.PrimaryIDOCollection.GetObjectProperty("ID", curIndex); if (childID == null) { return; } if (!IsDuplicateCampaignAccountRecord(primaryID, childID)) { newItem = MapCampaignAccount(primaryID, childID); req.Items.Add(newItem); } } } IDOClient.UpdateCollection(req); return; }
public void AddAccountOpportunity() { UpdateCollectionRequestData req = new UpdateCollectionRequestData(); req.IDOName = "CRMOPPORTUNITYRESELLER"; req.RefreshAfterUpdate = true; string accountID = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("ID"); string opportunityID = ThisForm.ModalChildForm.PrimaryIDOCollection.GetCurrentObjectProperty("ID"); IDOUpdateItem newItem; if (string.IsNullOrWhiteSpace(opportunityID)) { return; } string description = ThisForm.ModalChildForm.PrimaryIDOCollection.GetCurrentObjectProperty("Description"); if (IsDuplicate(opportunityID)) { Application.ShowMessage(Application.GetStringValue("mIsAlreadyAssociatedToThisAccount").Replace("%1", description)); return; } newItem = MapContactOpportunitItem(accountID, opportunityID); req.Items.Add(newItem); IDOClient.UpdateCollection(req); ThisForm.PrimaryIDOCollection.RefreshKeepCurIndex(); return; }
private void AssociateAccountContact() { var req = new UpdateCollectionRequestData { IDOName = "CRMContactAccount", RefreshAfterUpdate = true }; string accountId = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("ID"); int count = ThisForm.ModalChildForm.PrimaryIDOCollection.GetNumEntries(); for (int curIndex = 0; curIndex < count; curIndex++) { if (ThisForm.ModalChildForm.PrimaryIDOCollection.GetObjectProperty("CRMRecordSelected", curIndex) == "1") { string contactId = ThisForm.ModalChildForm.PrimaryIDOCollection.GetObjectProperty("ID", curIndex); var existingAssociation = IDOClient.LoadCollection("CRMContactAccount", "AccountID, ContactID", string.Format("AccountID = '{0}' AND ContactID = '{1}'", accountId, contactId), string.Empty, 1); if (existingAssociation.Items.Count == 0) { req.Items.Add(MapNewItem(contactId, accountId)); } //Application.ShowMessage(Application.GetStringValue("sRecordExisted")); } } try { IDOClient.UpdateCollection(req); } catch (Exception ex) { Application.ShowMessage(ex.Message); Application.DiagnosticsLog(ex.Message); } ThisForm.PrimaryIDOCollection.RefreshKeepCurIndex(); }
/// <summary> /// Insert trxHeader record with approval of adjustments /// Insert all trxLine record with adjustments under trxHeader /// </summary> public void Submit() { string trxHeaderIdoName = "CRMWarehouseLocationTrxHeader"; string trxType = "StockAdjust"; string todayDate = DateTime.UtcNow.ToString("yyyy-MM-ddThh:mm:ss.fffZ"); string stockBin = ThisForm.Variables("VarStockBin").Value; //INSERT TRX HEADER RECORD UpdateCollectionRequestData insert = new UpdateCollectionRequestData(trxHeaderIdoName); IDOUpdateItem itm = new IDOUpdateItem(UpdateAction.Insert); itm.Properties.Add("TrxType", trxType); itm.Properties.Add("TrxDate", todayDate); itm.Properties.Add("VanStockLocation", stockBin); itm.Properties.Add("Status", "Posted"); insert.Items.Add(itm); try { IDOClient.UpdateCollection(insert); } catch (Exception e) { Application.ShowMessage("Unable to insert record to " + trxHeaderIdoName + "\n" + e.Message); } Application.ShowMessage("Successfully submitted TrxHeader at " + todayDate); //GET TRX HEADER ID FOR TRX LINES LoadCollectionRequestData trxHeaderLoadRequest = new LoadCollectionRequestData(); trxHeaderLoadRequest.IDOName = trxHeaderIdoName; trxHeaderLoadRequest.PropertyList.Add("ID"); trxHeaderLoadRequest.Filter = "TrxDate = '" + todayDate + "'"; trxHeaderLoadRequest.OrderBy = ""; trxHeaderLoadRequest.RecordCap = 1; LoadCollectionResponseData trxHeaderLoadResponse = IDOClient.LoadCollection(trxHeaderLoadRequest); if (trxHeaderLoadResponse.Items.Count != 1) { Application.ShowMessage("Could not load " + trxHeaderIdoName + " record with TrxDate = " + todayDate); return; } //INSERT TRX LINE RECORD insert = new UpdateCollectionRequestData("CRMWarehouseStockLotLocationTrx"); ThisForm.PrimaryIDOCollection.First(); for (int i = 0; i < ThisForm.PrimaryIDOCollection.GetNumEntries() - 1; i++) { string trxHeader = trxHeaderLoadResponse[0, "ID"].Value; string productID = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("ProductID"); string locationID = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("LocationID"); string lotCode = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("StockLotCode"); string systemQuantity = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("QuantityOnHand"); string adjustment = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("Adjustment"); string reason = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("Reason"); Application.ShowMessage(productID + "\n" + locationID + "\n" + lotCode + "\n" + systemQuantity + "\n" + adjustment + "\n" + reason); //if adjustment is empty, skip if (adjustment.Equals("")) { ThisForm.PrimaryIDOCollection.Next(); continue; } itm = new IDOUpdateItem(UpdateAction.Insert); itm.Properties.Add("TrxHeader", trxHeader); itm.Properties.Add("ProductID", productID); itm.Properties.Add("LocationID", locationID); itm.Properties.Add("StockLotCode", lotCode); itm.Properties.Add("QuantityOnHand", systemQuantity); itm.Properties.Add("CountAdjustment", adjustment); itm.Properties.Add("Reason", reason); insert.Items.Add(itm); ThisForm.PrimaryIDOCollection.Next(); } try { IDOClient.UpdateCollection(insert); } catch (Exception e) { Application.ShowMessage("Unable to insert into CRMWarehouseStockLotLocationTrx\n" + e.Message); } }