【问题标题】:Acumatica customer mailing settings through API通过 API 设置 Acumatica 客户邮件设置
【发布时间】:2017-04-03 12:15:31
【问题描述】:

我正在尝试通过 Screen API 创建客户邮件设置。但是,我没有成功保存数据。

这是我的代码:

public static class CustomerManager
{
    private static Value CreateValue(
        string value,
        Command linkedCommand)
    {
        return new Value()
        {
            Value = value,
            LinkedCommand = linkedCommand
        };
    }

    private static Value CreateValueCommit(
        string value,
        Command linkedCommand)
    {
        return new Value()
        {
            Value = value,
            LinkedCommand = linkedCommand,
            Commit = true
        };
    }

    public static void ManageContact() {
        try {
            using (var context = WebServiceConnector.InitializeScreenWebService()) {
                var customerSchema = context.AR303000GetSchema();

                var commands = new List<Command>() {
                    CreateValueCommit("C00001", customerSchema.CustomerSummary.CustomerID),
                    CreateValueCommit("INVOICE", customerSchema.MailingSettingsMailings.MailingID),
                    CreateValue("mail@mail.com", customerSchema.MailingSettingsMailings.EmailAccountEmailAddress),
                    CreateValueCommit("InvoiceNotification", customerSchema.MailingSettingsMailings.NotificationTemplate),
                    customerSchema.MailingSettingsRecipients.ServiceCommands.NewRow,
                    CreateValueCommit("Contact", customerSchema.MailingSettingsRecipients.ContactType),
                    CreateValueCommit("Doe John, Dr.", customerSchema.MailingSettingsRecipients.ContactID),
                    customerSchema.Actions.Save,
                    customerSchema.CustomerSummary.CustomerID,
                    customerSchema.MailingSettingsMailings.EmailAccountEmailAddress,
                    customerSchema.MailingSettingsRecipients.ContactID
                };

                var customer = context.AR303000Submit(commands.ToArray());

                context.Logout();
            }
        }
        catch (Exception ex) {

            throw ex;
        }
    }
}

唯一正确保存的值是通知模板。

在调试时,我检查了邮件收件人,该值在我的客户退货对象中。但是客户屏幕上什么都没有:

【问题讨论】:

    标签: c# acumatica


    【解决方案1】:

    由于以下原因,邮件设置选项卡不是一件容易实现思想 Web 服务自动化的事情:

    • 初始邮件设置是在客户类别级别定义的。允许用户修改初始设置或创建新的分支特定设置。每个 MailingID/Branch 对只能定义一个邮件设置

    • 收件人网格仅显示为当前邮件设置定义的收件人

    • DisplayMode 设置为 Text 的电子邮件帐户列需要将最初生成的 FieldName 从 EMailAccountID 更改为 EMailAccountID!Address。否则 API 将忽略为此列定义的值:

      Content customerSchema = context.GetSchema();
      customerSchema.MailingSettingsMailings.EmailAccount.FieldName += "!Address";
      

      在 Aspx 中邮件网格的定义:

      <px:PXGrid ID="gridNS" runat="server" SkinID="DetailsInTab" Caption="Mailings" ... >
          ...
          <Levels>
              <px:PXGridLevel DataMember="NotificationSources" DataKeyNames="SourceID,SetupID">
                  <RowTemplate>
                      ...
                  </RowTemplate>
                  <Columns>
                      ...
                      <px:PXGridColumn DataField="EMailAccountID" DisplayMode="Text" Width="200px" />
                      ...
                  </Columns>
                  ...
              </px:PXGridLevel>
          </Levels>
      </px:PXGrid>
      

    以下是 3 个示例,展示了如何通过基于屏幕的 API 使用“邮件设置”选项卡:

    1. 为客户类级别定义的初始邮寄设置插入新收件人:

      Screen context = new Screen();
      context.CookieContainer = new System.Net.CookieContainer();
      context.Url = "http://localhost/StackOverflow/Soap/AR303000.asmx";
      context.Login(username, password);
      
      try
      {
          Content customerSchema = context.GetSchema();
          var commands = new Command[]
          {
              new Value
              {
                  Value = "ABCSTUDIOS",
                  LinkedCommand = customerSchema.CustomerSummary.CustomerID
              },
      
              new Key
              {
                  Value = "='INVOICE'",
                  FieldName = customerSchema.MailingSettingsMailings.MailingID.FieldName,
                  ObjectName = customerSchema.MailingSettingsMailings.MailingID.ObjectName
              },
              customerSchema.MailingSettingsMailings.MailingID,
      
              customerSchema.MailingSettingsRecipients.ServiceCommands.NewRow,
              new Value
              {
                  Value = "Contact",
                  LinkedCommand = customerSchema.MailingSettingsRecipients.ContactType,
              },
              new Value
              {
                  Value = "Harper, Travis",
                  LinkedCommand = customerSchema.MailingSettingsRecipients.ContactID,
                  Commit = true
              },
              customerSchema.Actions.Save
          };
          context.Submit(commands);
      }
      finally
      {
          context.Logout();
      }
      
    2. 要更新在客户类级别邮件设置中定义的初始邮件设置并为其添加新收件人:

      Screen context = new Screen();
      context.CookieContainer = new System.Net.CookieContainer();
      context.Url = "http://localhost/StackOverflow/Soap/AR303000.asmx";
      context.Login(username, password);
      
      try
      {
          Content customerSchema = context.GetSchema();
          customerSchema.MailingSettingsMailings.EmailAccount.FieldName += "!Address";
      
          var commands = new Command[]
          {
              new Value
              {
                  Value = "ACTIVESTAF",
                  LinkedCommand = customerSchema.CustomerSummary.CustomerID
              },
      
              new Key
              {
                  Value = "='INVOICE'",
                  FieldName = customerSchema.MailingSettingsMailings.MailingID.FieldName,
                  ObjectName = customerSchema.MailingSettingsMailings.MailingID.ObjectName
              },
              new Value
              {
                  Value = "admin@revisiontwo.com",
                  LinkedCommand = customerSchema.MailingSettingsMailings.EmailAccount,
                  Commit = true
              },
      
              customerSchema.MailingSettingsRecipients.ServiceCommands.NewRow,
              new Value
              {
                  Value = "Contact",
                  LinkedCommand = customerSchema.MailingSettingsRecipients.ContactType,
              },
              new Value
              {
                  Value = "Dunnaville, Linda",
                  LinkedCommand = customerSchema.MailingSettingsRecipients.ContactID,
                  Commit = true
              },
              customerSchema.Actions.Save
          };
          context.Submit(commands);
      }
      finally
      {
          context.Logout();
      }
      
    3. 创建新的特定于分支机构的邮件设置并为其添加新收件人:

      Screen context = new Screen();
      context.CookieContainer = new System.Net.CookieContainer();
      context.Url = "http://localhost/StackOverflow/Soap/AR303000.asmx";
      context.Login(username, password);
      
      try
      {
          Content customerSchema = context.GetSchema();
      
          customerSchema.MailingSettingsMailings.EmailAccount.FieldName += "!Address";
          var commands = new Command[]
          {
              new Value
              {
                  Value = "ABCVENTURE",
                  LinkedCommand = customerSchema.CustomerSummary.CustomerID
              },
      
              customerSchema.MailingSettingsMailings.ServiceCommands.NewRow,
              new Value
              {
                  Value = "INVOICE",
                  LinkedCommand = customerSchema.MailingSettingsMailings.MailingID,
              },
              new Value
              {
                  Value = "HQ",
                  LinkedCommand = customerSchema.MailingSettingsMailings.Branch,
              },
              new Value
              {
                  Value = "admin@revisiontwo.com",
                  LinkedCommand = customerSchema.MailingSettingsMailings.EmailAccount,
                  Commit = true
              },
      
              customerSchema.MailingSettingsRecipients.ServiceCommands.NewRow,
              new Value
              {
                  Value = "Contact",
                  LinkedCommand = customerSchema.MailingSettingsRecipients.ContactType,
              },
              new Value
              {
                  Value = "Palmer, Steve",
                  LinkedCommand = customerSchema.MailingSettingsRecipients.ContactID,
                  Commit = true
              },
              customerSchema.Actions.Save
          };
          context.Submit(commands);
      }
      finally
      {
          context.Logout();
      }
      

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-27
      • 2019-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-21
      • 1970-01-01
      相关资源
      最近更新 更多