public LoadCollectionResponseData getEventStatus(string eventName) { LoadCollectionRequestData Load = new LoadCollectionRequestData(); Load.IDOName = "EventStates"; Load.PropertyList.Add("EventName"); Load.PropertyList.Add("Status"); Load.PropertyList.Add("Originator"); Load.PropertyList.Add("EventParmId"); Load.Filter = "EventName = '" + eventName + "' AND Status = '2'"; Load.OrderBy = ""; Load.RecordCap = 100; LoadCollectionResponseData response = IDOClient.LoadCollection(Load); if (response.Items.Count > 0) { ThisForm.Variables("varDebug").Value += response[0, "EventName"].Value + "\n"; ThisForm.Variables("varDebug").Value += response[0, "Status"].Value + "\n"; ThisForm.Variables("varDebug").Value += response[0, "Originator"].Value + "\n"; for (int i = 0; i < response.Items.Count; i++) { ThisForm.Variables("varDebug").Value += response[i, "EventParmId"].Value + "\n"; } } return(response); }
public void SetReturnVariables() { var id = ThisForm.ModalChildForm.PrimaryIDOCollection.CurrentItem.Properties["ID"].GetValueOfString(string.Empty); var propList = "AlternateKeySuffix,ID"; var req = IDOClient.LoadCollection("CRMSalesOrder", propList, "ID = '" + id + "'", string.Empty, 1); var summary = req[0, "AlternateKeySuffix"].GetValue(string.Empty); var description = Application.GetStringValue("sSalesOrderInsert"); var jsonResult = string.Empty; var toastEntityFilter = string.Empty; description = description.Replace("%1", string.Format("[{0}]({1} {2})", summary, "CRMSalesOrder", id)); toastEntityFilter = string.Format("ID = '{0}'", id); var toastJson = new InvokeRequestData() { IDOName = "CRMToastService", MethodName = "GenerateToastJson", Parameters = new InvokeParameterList() { new InvokeParameter("Create"), new InvokeParameter(description), new InvokeParameter(string.Empty), new InvokeParameter("barcode"), new InvokeParameter() { ByRef = true, Value = jsonResult } } }; var response = IDOClient.Invoke(toastJson); jsonResult = response.Parameters[response.Parameters.Count - 1].Value; Application.DiagnosticsLog(jsonResult + Environment.NewLine + response.ReturnValue); Application.Variables("VarCRMToastEntityFilter").SetValue(toastEntityFilter); Application.Variables("VarCRMToastConfig").SetValue(jsonResult); }
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> /// 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 LoadDatesandTimes() { Application.DiagnosticsLog("KC_VarDt:" + ThisForm.Variables("VarDtModified").Value); Application.DiagnosticsLog("KC_VarDt:" + ThisForm.Variables("VarDtCreated").Value); var currentUser = Application.Variables("VarCRMUserID").GetValueOfString(string.Empty); if (string.IsNullOrEmpty(currentUser)) { currentUser = Application.Variables("VarMGUserName").GetValueOfString(string.Empty); } LoadCollectionResponseData loadResponse = IDOClient.LoadCollection("CRMUserNames", "CRMUserID,LocalTimeZone", string.Format("CRMUserID = '{0}' OR Username = '******'", currentUser), "", 0); var timeZone = TimeZoneInfo.Local.Id; if (loadResponse.Items.Count > 0) { timeZone = loadResponse[0, 1].Value; Application.DiagnosticsLog(string.Format("User '{0}' time zone set to: {1}", currentUser, timeZone)); if (string.IsNullOrEmpty(timeZone)) { // Fall back to local time timeZone = TimeZoneInfo.Local.Id; Application.ShowMessage(Application.GetStringValue("mUserTimeZoneNotSet")); } } var now = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, timeZone); var modifiedDate = ThisForm.Variables("VarDtModified").GetValueOfDateTime(RoundUp(now, TimeSpan.FromMinutes(5))); var createdDate = ThisForm.Variables("VarDtCreated").GetValueOfDateTime(RoundUp(now, TimeSpan.FromMinutes(5))); ThisForm.Variables("VarDtModified").SetValue(ConvertDtToTimeZone(modifiedDate, timeZone)); ThisForm.Variables("VarDtCreated").SetValue(ConvertDtToTimeZone(createdDate, timeZone)); }
public void EmailRelated() { var emailList = string.Empty; var contactIdList = string.Empty; var emailQueryFilter = "EntityID in ({0}) and IsPrimary = 1"; var accountId = ThisForm.PrimaryIDOCollection.CurrentItem.Properties["ID"].GetValueOfString(string.Empty); var acctFilter = string.Format("AccountID='{0}'", accountId); var req = new LoadCollectionRequestData("CRMContact", "ID", acctFilter, "", 0); Application.DiagnosticsLog("EmailRelated: Load Collection contact"); var resp = IDOClient.LoadCollection(req); var mailToUrl = "mailto:"; if (resp.Items != null && resp.Items.Count > 0) { for (int i = 0; i < resp.Items.Count; i++) { Application.DiagnosticsLog("EmailRelated: " + resp.Items.Count.ToString()); var tempId = resp.Items[i].PropertyValues[0].Value; // filter ID values need wrapped in single quotes to pass through load collection if (!string.IsNullOrEmpty(contactIdList)) { contactIdList += @","; } contactIdList += @"'" + tempId + @"'"; } } var emailFilter = string.Format(emailQueryFilter, contactIdList); if (!string.IsNullOrEmpty(contactIdList)) { var emailReq = new LoadCollectionRequestData("CRMEmail", "Address", emailFilter, "Address", 0); Application.DiagnosticsLog("EmailRelated: Load Collection email"); var emailResp = IDOClient.LoadCollection(emailReq); for (int i = 0; i < emailResp.Items.Count; i++) { var tempEmail = emailResp.Items[i].PropertyValues[0].Value; if (!string.IsNullOrEmpty(emailList)) { emailList += ";"; } emailList += tempEmail; } } mailToUrl += emailList; ThisForm.Variables("VarMailToUrl").SetValue(mailToUrl); ThisForm.Components["linkEmailRelated"].SetValue(mailToUrl); ThisForm.Components["linkEmailRelated"].Caption = Application.GetStringValue("sEmailRelated"); }
private bool IsDuplicateAccountPlanningCycleRecord(string AccountID, string childPropertyID) { bool isExist = false; var response = IDOClient.LoadCollection("CRMPlanningCycleAssociations", "ID", string.Format("AccountID = '{0}' and PlanningCycleID = '{1}'", AccountID, childPropertyID), "", -1).Items.Count; if (response > 0) { isExist = true; } return(isExist); }
private bool IsDuplicateCampaignAccountRecord(string AccountID, string childPropertyID) { bool isExist = false; var response = IDOClient.LoadCollection(string.Format("CRMCampaignAccount"), "ID", string.Format("AccountID = '{0}' and CampaignID = '{1}'", AccountID, childPropertyID), "", -1).Items.Count; if (response > 0) { isExist = true; } return(isExist); }
private bool IsDuplicate(string opportunityID) { string accountID = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("ID"); var records = IDOClient.LoadCollection("CRMOPPORTUNITYRESELLER", "OPPORTUNITYID", "RESELLERID='" + accountID + "'", string.Empty, -1); if (records.Items != null && records.Items.Count > 0 && (records.Items.FindIndex(item => opportunityID.Equals(item.PropertyValues[0].Value)) >= 0)) { return(true); } return(false); }
public void ConfigureComponent() { // Custom Setting determines if the VisitPlanning related items can be visible var oResp = IDOClient.LoadCollection("CRMCustomSetting", "DataValue", "Category = 'Visit Planning'", string.Empty, 1); if (oResp.Items.Count > 0) { var settingValue = oResp.Items[0].PropertyValues[0].GetValue(string.Empty); visitOverride = !settingValue.Equals("False", StringComparison.OrdinalIgnoreCase); } EnableComponents(visitOverride); }
/// <summary> /// Gets the number of activities for the Account. That will be used as badge to display in Activity Related section /// </summary> public void GetUpcomingActivitiesCount() { string ActivityCount = "0"; string accountId = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("ID"); if (accountId != null) { LoadCollectionResponseData loadresponse = IDOClient.LoadCollection("CRMACCOUNTACTIVITIESRRELATEDVIEWs", "Summary", "EntityID='" + accountId + "' and EntityType='CRMAccount' and Completed IS NULL and IsFirstUncompleted=1", "", -1); if (loadresponse != null) { ActivityCount = loadresponse.Items.Count == 1 ? "STRINGS(sCRMItemCount)" : string.Format("FORMAT(sCRMItemsCount,{0})", loadresponse.Items.Count.ToString()); } } ThisForm.Variables("VarActivityCount").SetValue(ActivityCount); }
public void CalculateAccountKPIs(string username) { var req = new LoadCollectionRequestData("CRMAccountManagerKPI", "WinPercent, TotalPotential, TotalSales", string.Format("Username='******'", username), "", 1); var resp = IDOClient.LoadCollection(req); decimal salesPotential = 0.00M, actualSales = 0.00M, wins = 0.00M; if (resp.Items != null && resp.Items.Count > 0) { foreach (var t in resp.Items) { if (t.PropertyValues.Count > 0 && !string.IsNullOrEmpty(t.PropertyValues[0].Value)) { wins = t.PropertyValues[0].GetValue <decimal>(); } if (t.PropertyValues.Count > 1 && !string.IsNullOrEmpty(t.PropertyValues[1].Value)) { salesPotential = t.PropertyValues[1].GetValue <decimal>(); } if (t.PropertyValues.Count > 2 && !string.IsNullOrEmpty(t.PropertyValues[2].Value)) { actualSales = t.PropertyValues[2].GetValue <decimal>(); } } } ThisForm.Variables("VarKPIPipelineData").SetValue(FormatNumberForKPIDisplay(salesPotential)); ThisForm.Variables("VarKPIWinsData").SetValue(FormatNumberForKPIDisplay(actualSales)); if (wins > 0) { ThisForm.Variables("VarKPIWinRateData").SetValue(wins.ToString("P0", new NumberFormatInfo { PercentPositivePattern = 1, PercentNegativePattern = 1 })); } else { ThisForm.Variables("VarKPIWinRateData").SetValue("N/A"); } }
public LoadCollectionResponseData getEventOutputParameters(string eventParmId) { LoadCollectionRequestData Load = new LoadCollectionRequestData(); Load.IDOName = "EventOutputParameters"; Load.PropertyList.Add("Name"); Load.PropertyList.Add("Value"); Load.PropertyList.Add("Originator"); Load.PropertyList.Add("EventParmId"); Load.PropertyList.Add("EventName"); Load.Filter = "EventParmId = '" + eventParmId + "'"; Load.OrderBy = ""; Load.RecordCap = 10; LoadCollectionResponseData response = IDOClient.LoadCollection(Load); //ThisForm.Variables("varDebug").Value += "\n\nEvent Output Parameters\n"; //ThisForm.Variables("varDebug").Value += response[0, "EventName"].Value + "\n"; //ThisForm.Variables("varDebug").Value += response[0, "EventParmId"].Value + "\n"; //ThisForm.Variables("varDebug").Value += response[0, "Originator"].Value + "\n"; return(response); }
public void OnLocationChange() { if (string.IsNullOrWhiteSpace(ThisForm.Variables("VarAccountIdComponentKey").Value) || string.IsNullOrWhiteSpace(ThisForm.Variables("VarLocationIdComponentKey").Value) || string.IsNullOrWhiteSpace(ThisForm.Variables("VarAccountingEntityComponentKey").Value)) { return; } var accountIdComponentKey = ThisForm.Variables("VarAccountIdComponentKey").Value; var locationIdComponentKey = ThisForm.Variables("VarLocationIdComponentKey").Value; var accountingEntityComponentKey = ThisForm.Variables("VarAccountingEntityComponentKey").Value; if (!ThisForm.Components.ContainsKey(accountIdComponentKey) || !ThisForm.Components.ContainsKey(locationIdComponentKey) || !ThisForm.Components.ContainsKey(accountingEntityComponentKey)) { return; } var integrationEnabled = Application.Variables("VarCRMIsBOEEnabled").Value; var accountID = ThisForm.Components[accountIdComponentKey].GetValueOfString(string.Empty); if (integrationEnabled == "1" && string.IsNullOrWhiteSpace(accountID)) { var locationId = ThisForm.Components[locationIdComponentKey].GetValueOfString(string.Empty); if (string.IsNullOrWhiteSpace(locationId)) { ThisForm.Components[accountingEntityComponentKey].SetValue(string.Empty); return; } var request = new LoadCollectionRequestData("CRMLocation", "SORAccountingEntityID", string.Format("ID='{0}'", locationId), string.Empty, 1); var response = IDOClient.LoadCollection(request); if (response != null && response.Items.Count > 0) { ThisForm.Components[accountingEntityComponentKey].SetValue(response.Items[0].PropertyValues[0].GetValue(string.Empty)); } } }
private void SetAddress() { var entityID = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("ID"); var filter = string.Format("EntityID='{0}'", entityID); // Is VarAddressTypeFilter set? var addressTypeFilter = ThisForm.Variables("VarAddressTypeFilter").GetValueOfString(string.Empty); if (!string.IsNullOrEmpty(addressTypeFilter)) { filter = string.Format("{0} and {1}", filter, addressTypeFilter); } var resp = IDOClient.LoadCollection("CRMAddress", "ID,MailingAddressDer", filter, string.Empty, 1); if (resp.Items.Count > 0) { ThisForm.Components["txtAddress"].SetValue(resp[0, "MailingAddressDer"].GetValue(string.Empty)); if (string.IsNullOrEmpty(ThisForm.Variables("VarAddressID").GetValueOfString(string.Empty))) { ThisForm.Variables("VarAddressID").SetValue(resp[0, "ID"].GetValue(string.Empty)); } } }
/// <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); } }
/// <summary> /// Validate the account if the owner is everyone or not /// Everyone: does not allow delete /// </summary> public void ValidateDelete() { string selectedOwner = "SecCodeID"; string selectedAccountName = "AccountName"; string showDetail = ThisForm.Variables("VarShowDetail").GetValue <string>(); string itemsCannotbeDeleted = string.Empty; if (string.Equals(showDetail, "0")) { itemsCannotbeDeleted = string.Empty; var rowCount = ThisForm.PrimaryIDOCollection.GetNumEntries(); for (var i = 0; i < rowCount; i++) { var currentRowValue = ThisForm.PrimaryIDOCollection.GetObjectProperty(selectionProperty, i); var currentRowOwner = ThisForm.PrimaryIDOCollection.GetObjectProperty(selectedOwner, i); var currentAccountName = ThisForm.PrimaryIDOCollection.GetObjectProperty(selectedAccountName, i); var filter = string.Format("ID=N'{0}' and Type=N'{1}'", currentRowOwner, "System"); var AccountInfo = IDOClient.LoadCollection("CRMSeccodeView", "ID", filter, string.Empty, -1); if (currentRowValue == "1") { if (AccountInfo.Items.Count > 0) { itemsCannotbeDeleted = itemsCannotbeDeleted + currentAccountName + ","; } else { ThisForm.GenerateEvent("StdFormDelete"); return; } } } } else { itemsCannotbeDeleted = string.Empty; var currentRowOwner = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty(selectedOwner); var currentAccountName = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty(selectedAccountName); var filter = string.Format("ID=N'{0}' and Type=N'{1}'", currentRowOwner, "System"); var AccountInfo = IDOClient.LoadCollection("CRMSeccodeView", "ID", filter, string.Empty, -1); if (AccountInfo.Items.Count > 0) { itemsCannotbeDeleted = currentAccountName; } else { ThisForm.GenerateEvent("StdFormDelete"); return; } } if (!string.IsNullOrEmpty(itemsCannotbeDeleted)) { Application.ShowMessage(Application.GetStringValue("sCannotDeleteAccount").Replace("%1", itemsCannotbeDeleted)); } }