/// <summary> /// Creates the Acumatica Employee as a Smartsheet User /// </summary> /// <param name="bAccountID">Employee ID</param> /// <param name="smartsheetClient">Smartsheet SDK Client</param> /// <returns></returns> public User CreateSmartsheetUser(int?bAccountID, SmartsheetClient smartsheetClient) { BAccount bAccountRecord = PXSelect <BAccount, Where <BAccount.bAccountID, Equal <Required <BAccount.bAccountID> > > > .Select(Base, bAccountID); PX.Objects.CR.Contact contactRecord = PXSelect <PX.Objects.CR.Contact, Where <PX.Objects.CR.Contact.contactID, Equal <Required <PX.Objects.CR.Contact.contactID> > > > .Select(Base, bAccountRecord.DefContactID); if (contactRecord == null) { throw new PXException(string.Format(SmartsheetConstants.Messages.ERROR_CONTACT, bAccountRecord.AcctName)); } try { User ssUserNew = new User(); ssUserNew.Email = contactRecord.EMail; ssUserNew.FirstName = contactRecord.FirstName; ssUserNew.LastName = contactRecord.LastName; ssUserNew.Admin = false; ssUserNew.LicensedSheetCreator = false; User updatedUser = smartsheetClient.UserResources.AddUser(ssUserNew, false, false); return(updatedUser); } catch (Exception e) { PXTrace.WriteError(e.Message); return(null); } }
private BAccount FindAccount(PXGraph graph, Contact contact) { if (contact == null || contact.BAccountID == null) return null; PXSelect<BAccount, Where<BAccount.bAccountID, Equal<Required<BAccount.bAccountID>>>>. Clear(graph); var account = (BAccount)PXSelect<BAccount, Where<BAccount.bAccountID, Equal<Required<BAccount.bAccountID>>>>. Select(graph, contact.BAccountID); return account; }
private void FindOwner(PXGraph graph, IAssign source, out Contact employee, out Users user) { employee = null; user = null; if (source == null || source.OwnerID == null) return; PXSelectJoin<Users, LeftJoin<EPEmployee, On<EPEmployee.userID, Equal<Users.pKID>>, LeftJoin<Contact, On<Contact.contactID, Equal<EPEmployee.defContactID>>>>, Where<Users.pKID, Equal<Required<Users.pKID>>>>. Clear(graph); var row = (PXResult<Users, EPEmployee, Contact>)PXSelectJoin<Users, LeftJoin<EPEmployee, On<EPEmployee.userID, Equal<Users.pKID>>, LeftJoin<Contact, On<Contact.contactID, Equal<EPEmployee.defContactID>>>>, Where<Users.pKID, Equal<Required<Users.pKID>>>>. Select(graph, source.OwnerID); employee = (Contact)row; user = (Users)row; }
private Mailbox GenerateAddress(Contact employee, Users user) { string displayName = null; string address = null; if (user != null && user.PKID != null) { var userDisplayName = user.FullName.With(_ => _.Trim()); if (!string.IsNullOrEmpty(userDisplayName)) displayName = userDisplayName; var userAddress = user.Email.With(_ => _.Trim()); if (!string.IsNullOrEmpty(userAddress)) address = userAddress; } if (employee != null && employee.BAccountID != null) { var employeeDisplayName = employee.DisplayName.With(_ => _.Trim()); if (!string.IsNullOrEmpty(employeeDisplayName)) displayName = employeeDisplayName; var employeeAddress = employee.EMail.With(_ => _.Trim()); if (!string.IsNullOrEmpty(employeeAddress)) address = employeeAddress; } return string.IsNullOrEmpty(address) ? null : new Mailbox(displayName, address); }
private static void ExtractAttendeeInfo(Users user, Contact contact, out string fullName, out string email) { fullName = user.FullName; email = user.Email; if (contact.DisplayName != null && contact.DisplayName.Trim().Length > 0) fullName = contact.DisplayName; if (contact.EMail != null && contact.EMail.Trim().Length > 0) email = contact.EMail; }
public Recipient(object entity, Contact contact, string format) { Entity = entity; Contact = contact; Format = format; }
public Recipient(Contact contact, string format) { Entity = contact; Contact = contact; Format = format; }