简体   繁体   English

在Dynamics CRM插件中使用C#创建PDF的步骤是什么

[英]What are the steps to create a PDF using C# in a Dynamics CRM plugin

I have read all the documentation on 3.0 API. 我已经阅读了所有关于3.0 API的文档。 Please don't send me there again. 请不要再送我到那里。 I can create a template on DocuSign with Custom Fields and send it out in an envelope but cannot seem to fill in custom fields (tabs?) with values from my application. 我可以在带有自定义字段的DocuSign上创建一个模板,然后将其发送到信封中,但是似乎无法用我的应用程序中的值填充自定义字段(标签?)。 Can anyone tell me the exact approach? 谁能告诉我确切的方法? IE: I have tried authenticate-->CreateEnvelopeFromTemplates-->SendEnvelope and just get empty form fields. IE:我尝试过身份验证-> CreateEnvelopeFromTemplates-> SendEnvelope,只获取空的表单字段。 I tried authenticate-->CreateEnvelope->SendEnvelope ....empty fields. 我尝试身份验证-> CreateEnvelope-> SendEnvelope ....空字段。 I won't be able to host the file on the local file system anyway, so I think that would be a dead end even if it did work (CRM Online). 无论如何,我将无法在本地文件系统上托管该文件,所以我认为即使该文件能够正常工作也将是死胡同(CRM在线)。 here's kind of what the template is like: ! 模板是这样的: https://dl.dropboxusercontent.com/u/24627933/DocuSign.PNG here's what I thought was the most promising example: https://dl.dropboxusercontent.com/u/24627933/DocuSign.PNG这是我认为最有希望的示例:

string auth = "<DocuSignCredentials><Username>" + _userName
     + "</Username><Password>" + _password
     + "</Password><IntegratorKey>" + _IntegratorKey
     + "</IntegratorKey></DocuSignCredentials>";

APIServiceSoapClient _apiClient = new APIServiceSoapClient("APIServiceSoap", _apiUrl);

/* tried this too
Tab RoutingNumber = new Tab()
{
    Name = "RoutingNumber",
    Type = TabTypeCode.Custom,
    Bold = true,
    Value = "1234 555 765"
};
Tab PayeeName = new Tab()
{
    Name = "PayeeName",
    Value = "PaiYee Na Me",
    Bold = false,
    Type = TabTypeCode.Custom
};
  */

// Construct all the recipient information
Recipient[] recipients = CreateOneSigner();
TemplateReferenceRoleAssignment[] finalRoleAssignments = new TemplateReferenceRoleAssignment[1];
finalRoleAssignments[0] = new TemplateReferenceRoleAssignment();
finalRoleAssignments[0].RoleName = recipients[0].RoleName;
finalRoleAssignments[0].RecipientID = recipients[0].ID;

// Use a server-side template -- you could make more than one of these
TemplateReference templateReference = new TemplateReference();
templateReference.TemplateLocation = TemplateLocationCode.Server;
templateReference.Template = "B3DAD8FD-1B48-4C62-9DB6-A48E5C5B40DC";
//templateReference.Template = "ABE98BE7-A400-493B-A3A3-BA489CEEA166"; 
templateReference.RoleAssignments = finalRoleAssignments;
templateReference.AdditionalTabs = new Tab[] { RoutingNumber, PayeeName };

// Construct the envelope information
EnvelopeInformation envelopeInfo = new EnvelopeInformation();
envelopeInfo.AccountId = _accountId;
envelopeInfo.Subject = "Irrevocable Commission Test";
envelopeInfo.EmailBlurb = "This is the Irrevocable Commission Disbursement Authorization form related to your Advance Pay request.";



CustomField Company = new CustomField()
{
    Name = "Company",
    Value = "Some company.",
    CustomFieldTypeSpecified = true,
    CustomFieldType = CustomFieldType.Text,
    Show = "Yes",
    Required = "Yes"
};
CustomField PayeeName = new CustomField()
{
    Name = "PayeeName",
    Value = "some name",
    CustomFieldTypeSpecified = true,
    CustomFieldType = CustomFieldType.Text,
    Show = "Yes",
    Required = "Yes"
};
CustomField RoutingNumber = new CustomField()
{
    Name = "RoutingNumber",
    Value = "my routing num",
    CustomFieldTypeSpecified = true,
    CustomFieldType = CustomFieldType.Text,
    Show = "Yes",
    Required = "Yes"
};
CustomField SendToName = new CustomField()
{
    Name = "SendToName",
    Value = "Residential Advance",
    CustomFieldTypeSpecified = true,
    CustomFieldType = CustomFieldType.Text,
    Show = "Yes",
    Required = "Yes"
};
CustomField AccountNumber = new CustomField()
{
    Name = "AccountNumber",
    Value = "my account ",
    CustomFieldTypeSpecified = true,
    CustomFieldType = CustomFieldType.Text,
    Show = "Yes",
    Required = "Yes"
};
CustomField AgentName = new CustomField()
{
    Name = "AccountNumber",
    Value = "my agent ",
    CustomFieldTypeSpecified = true,
    CustomFieldType = CustomFieldType.Text,
    Show = "Yes",
    Required = "Yes"
};
envelopeInfo.CustomFields = new CustomField[] { 
    Company, PayeeName, RoutingNumber, AccountNumber, SendToName
};

recipients[0].CustomFields = new CustomField[] {
    Company, PayeeName, RoutingNumber, AccountNumber, SendToName
};

using (var scope = new System.ServiceModel.OperationContextScope(_apiClient.InnerChannel))
{
    var httpRequestProperty = new System.ServiceModel.Channels.HttpRequestMessageProperty();
    httpRequestProperty.Headers.Add("X-DocuSign-Authentication", auth);
    System.ServiceModel.OperationContext.Current.OutgoingMessageProperties[System.ServiceModel.Channels.HttpRequestMessageProperty.Name] =
        httpRequestProperty;

    EnvelopeStatus status1 =
        _apiClient.CreateEnvelopeFromTemplates(new TemplateReference[] { templateReference },
                                                recipients,
                                                envelopeInfo,
                                                false);

    Console.WriteLine(status1);

    if (status1.Status.ToString() == "Created")
    {
        EnvelopeStatus sendStatus = _apiClient.SendEnvelope(status1.EnvelopeID, _accountId);
    }
}

I believe you need to use the tabLabel property in order to populate the data field. 我相信您需要使用tabLabel属性才能填充数据字段。 Try using something like this: 尝试使用如下所示的内容:

CustomField AccountNumber = new CustomField()
    {
        TabLabel = "AccountNumber",
        Name = "AccountNumber",
        Value = "my account ",
        CustomFieldTypeSpecified = true,
        CustomFieldType = CustomFieldType.Text,
        Show = "Yes",
        Required = "Yes"
    };

It appears that the objects used in the C# examples and suggested above are not correct. 看来在C#示例中使用的对象以及上面建议的对象是不正确的。 The values now show up when I use TemplateReferenceFieldDataDataValue and add that as FieldData.DataValues. 现在,当我使用TemplateReferenceFieldDataDataValue并将其添加为FieldData.DataValues时,将显示这些值。

        templateReference.RoleAssignments = finalRoleAssignments;
        var dataFieldValues = new TemplateReferenceFieldDataDataValue[3];
        dataFieldValues[0] = new TemplateReferenceFieldDataDataValue();
        dataFieldValues[0].TabLabel = "RoutingNumber";
        dataFieldValues[0].Value = "R12345678";
        dataFieldValues[1] = new TemplateReferenceFieldDataDataValue();
        dataFieldValues[1].TabLabel = "AccountNumber";
        dataFieldValues[1].Value = "A87654321";
        dataFieldValues[2] = new TemplateReferenceFieldDataDataValue();
        dataFieldValues[2].TabLabel = "Escrow";
        dataFieldValues[2].Value = "E777333";

        templateReference.FieldData = new TemplateReferenceFieldData();
        templateReference.FieldData.DataValues = dataFieldValues;

Hope that saves someone else some time. 希望可以节省一些时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM