Anchor tags are not showing up in the document - salesforce

Anchor tags are not showing up in the document
We have a 14 page document where the users will have to sign at the end of the Document on the field specified. The Document pdf looks like '
Where near the By field I have /s1/ tag which is invisible. And also in the Docusign custom button Controller I have the code like
................
Attachment att = [Select id,Name,Body,parentid from Attachment where parentid =: OppLst.id order by createddate DESC LIMIT 1 ];
DocuSignTK.Document document = new DocuSignTK.Document();
document.ID = 1;
document.Name = 'Quote Document';
document.FileExtension = 'html';
document.pdfBytes = EncodingUtil.base64Encode(attach.Body);
DocuSignTK.Recipient recipient = new DocuSignTK.Recipient();
recipient.Email = 'dh#gmail.com';
recipient.UserName = 'Dh';
recipient.ID = 1;
recipient.Type_x = 'Signer';
recipient.RoutingOrder = 1;
// The signer tab...
DocuSignTK.Tab signHereTab = new DocuSignTK.Tab();
signHereTab.Type_x = 'SignHere';
signHereTab.AnchorTabItem = new DocuSignTK.AnchorTab();
signHereTab.AnchorTabItem.AnchorTabString = 'signer1sig';
signHereTab.AnchorTabItem.XOffset = 8;
signHereTab.RecipientID = 1;
signHereTab.Name = 'Please sign here';
signHereTab.ScaleValue = 1;
signHereTab.TabLabel = 'signer1sig';
// The dateSigned tab
DocuSignTK.Tab dateSignedTab = new DocuSignTK.Tab();
dateSignedTab.Type_x = 'DateSigned';
dateSignedTab.AnchorTabItem = new DocuSignTK.AnchorTab();
dateSignedTab.AnchorTabItem.AnchorTabString = 'signer1date';
dateSignedTab.AnchorTabItem.YOffset = -6;
dateSignedTab.RecipientID = 1;
dateSignedTab.Name = 'Date Signed';
dateSignedTab.TabLabel = 'date_signed';
// Create an envelope and fill it in
DocuSignTK.Envelope envelope = new DocuSignTK.Envelope();
envelope.Subject = 'Please sign the Quote Document';
envelope.AccountId = account_id;
envelope.Tabs = new DocuSignTK.ArrayOfTab();
envelope.Tabs.Tab = new DocuSignTK.Tab[2];
envelope.Tabs.Tab.add(signHereTab);
envelope.Tabs.Tab.add(dateSignedTab);
envelope.Recipients = new DocuSignTK.ArrayOfRecipient();
envelope.Recipients.Recipient = new DocuSignTK.Recipient[1];
envelope.Recipients.Recipient.add(recipient);
envelope.Documents = new DocuSignTK.ArrayOfDocument();
envelope.Documents.Document = new DocuSignTK.Document[1];
envelope.Documents.Document.add(document);
if (String.isNotBlank(email_message))
{
envelope.EmailBlurb = email_message;
}
In the Docusign email it doesn't show anything
How to make the tags available so it is easy for the user to click and Sign.

the string that you use in your document to "anchor" the tabs should be the same that you specify in your tab AnchorTabString property.
You mentioned that the document has an invisible /s1/ tag in the text, but it looks like in your code you are setting a different value for the anchor string:
signHereTab.AnchorTabItem.AnchorTabString = 'signer1sig';
if you update this value to match the /s1/ value in your document it should work.
One way to troubleshoot this would be to log into your DocuSign account, create a new envelope using the document above, add a recipient and go to the tagger page.
Once in the tagger page you can use the "auto-place" feature, which is the same as the anchor strings, to test that the string that you want to use as an anchor can be found in the document.
Once you verify that you have the right string, you could use that string in your API call and things should work.
How to use the auto-place feature:
https://support.docusign.com/en/guides/AutoPlace-New-DocuSign-Experience

Related

Salesforce updating metadata record using apex

'I am trying to update a salesforce metadata record via Apex. here is my code:
Metadata.DeployContainer mdContainer = new Metadata.DeployContainer();
for(Omni_Routing_Skillset__mdt md: omnimetadata) {
Metadata.CustomMetadata customMetadata = new Metadata.CustomMetadata();
customMetadata.fullName = md.DeveloperName; //custom metadata name
customMetadata.Label = md.MasterLabel;
Metadata.CustomMetadataValue customField1 = new Metadata.CustomMetadataValue(); //the values you're changing/updating
customField1.field = 'Omni_Routing_Skillset__mdt.Skill_Level__c'; //the custom field API Name that you're wanting to insert/update a value of
customField1.value = skillsAndValues.get(md.MasterLabel);
customMetadata.values.add(customField1);//add the changes to list of changes to be deployed
mdContainer.addMetadata(customMetadata);
System.debug('customMetadata: ' + customMetadata);
}
//MetadataDeploy callback = new MetadataDeploy();
Id jobId = Metadata.Operations.enqueueDeployment(mdContainer, null);
This kicks off the deployment but i get the following error:
**Must specify the name in the CustomMetadataType.CustomMetadata format, Current Name: Team_2_SEP, Required Delimiter: .**
I am not sure how to fix this, can anyone please advise?
Thanks!
The name would be Omni_Routing_Skillset__mdt.Team_2_SEP you're only passing in Team_2_SEP.
You can reference this method:
public static void updateExisitingMetadatRecord() {
List<Metadata_Creditional__mdt> metadatList = [SELECT Id, DeveloperName,
MasterLabel FROM Metadata_Creditional__mdt WHERE DeveloperName='MyTest'];
Metadata.CustomMetadata metadataRec = new Metadata.CustomMetadata();
metadataRec.fullName =
'Metadata_Creditional__mdt.'+metadatList[0].DeveloperName;
metadataRec.label = metadatList[0].MasterLabel;
//provide the value for the fields and add it to custom metadata instance
Metadata.CustomMetadataValue totalPurchasetoUpdate = new
Metadata.CustomMetadataValue();
totalPurchasetoUpdate.field = 'Secret_Key__c';
totalPurchasetoUpdate.value = 'Change Secreet Value';
metadataRec.values.add(totalPurchasetoUpdate);
Metadata.DeployContainer mdContainer = new Metadata.DeployContainer();
mdContainer.addMetadata(metadataRec);
Metadata.Operations.enqueueDeployment(mdContainer, null);
}

Relate a Docusign Envelope to a Salesforce Custom object

I have a Template created in DS which contains custom tags which are mapped to Salesforce fields. The template works well when used via the JS button example code provided by DS and the fields appear as expected.
I am now trying to automate the process using the Docusign SOAPAPI. When creating the envelope the custom fields aren't populated; even the signer fields.
Below is my code:-
DocusignAPI.ArrayOfRecipient1 recipients = new DocusignAPI.ArrayOfRecipient1();
recipients.Recipient = new list<DocusignAPI.Recipient>();
DocusignAPI.Recipient recipient = new DocusignAPI.Recipient();
recipient.Email = signer_email;
recipient.UserName = signer_name;
recipient.ID = 1;
recipient.Type_x = 'Signer';
recipient.RoutingOrder = 1;
recipients.Recipient.add(recipient);
DocusignAPI.ArrayOfTemplateReference templateReferences = new DocusignAPI.ArrayOfTemplateReference();
templateReferences.TemplateReference = new list<DocusignAPI.TemplateReference>();
DocusignAPI.TemplateReference templateReference = new DocusignAPI.TemplateReference();
TemplateReference.Template = '6bc2930f-6d46-4804-a9fc-69d1cf3ebe09';
templateReference.TemplateLocation = 'Server';
templateReferences.TemplateReference.add(templateReference);
DocusignAPI.EnvelopeInformation ei = new DocusignAPI.EnvelopeInformation();
ei.AccountId = account_id;
ei.Subject = 'Lorem Ipsum';
ei.EmailBlurb = 'More text...';
// Create an envelope and fill it in
DocusignAPI.CustomField field = new DocusignAPI.CustomField ();
field.Name = 'DSFSSourceObjectId';
field.Value = 'a1qW0000000vMCj';
field.Show = 'false';
field.CustomFieldType = 'Text';
DocusignAPI.ArrayOfCustomField arrayOfCustomFields = new DocusignAPI.ArrayOfCustomField();
arrayOfCustomFields.CustomField = new list<DocusignAPI.CustomField>();
arrayOfCustomFields.CustomField.add(field);
ei.CustomFields = arrayOfCustomFields;
try {
DocusignAPI.EnvelopeStatus result = api_sender.CreateEnvelopeFromTemplates(templateReferences, recipients, ei, true);
envelope_id = result.EnvelopeID;
System.debug('Returned successfully, envelope_id = ' + envelope_id );
} catch ( CalloutException e) {
System.debug('Exception - ' + e );
error_code = 'Problem: ' + e;
error_message = error_code;
}
All customtags are related to my custom object with id defined in the CustomField above.
Any help gratefully appreciated.
Turns out I need to add in the object API name to the Id. Solution is:-
DocusignAPI.CustomField field = new DocusignAPI.CustomField ();
field.Name = 'DSFSSourceObjectId';
field.Value = 'a1qW0000000vMCj~Property__c';
field.Show = 'false';
field.CustomFieldType = 'Text';

Visualforce email template unit test

I have a trigger that sends an email using a VF template. I'm trying to write a unit test for that code, but keep running into a problem when trying to create the test data.
Here is my test method:
static TestMethod void testQuestionAttachment(){
Id profileId = SYSTEM_ADMIN_PROFILE_ID;
List<User> users = TestUtils.createUsers(profileId, 1);
insert users;
string templateText = '<messaging:emailTemplate subject="{!relatedTo.Name}" recipientType="User" relatedToType="Cutom_Object__c"><messaging:htmlEmailBody ><ul><li>test content</li></ul></messaging:htmlEmailBody></messaging:emailTemplate>';
EmailTemplate template = new EmailTemplate(
developerName = 'TestEmailVFTemplate',
TemplateType= 'visualforce',
FolderId = users[0].Id,
Name = 'TestEmailVFTemplate',
IsActive = true);
template.HtmlValue = templateText;
template.Body = templateText;
System.runAs(users[0]){
insert template;
}
...
And it fails with FIELD_INTEGRITY_EXCEPTION, <messaging:emailTemplate> is required and must be the outermost tag in the markup at line 1 column 1: [Markup].
I really don't understand why this isn't working. I must be missing something...
The issue is with your TemplateType = 'Visualforce'. Instead change it to template.Markup=templateText;. Markup field can be used to assign the body of visualforce template. I tried it in my test class.
Refer below example:
static #isTest void myTest () {
Profile pf = [SELECT Id,Name FROM Profile WHERE Name = 'System Administrator' LIMIT 1];
User usr = new User(
Alias = 'usralias',
Email = 'theuser#email.com',
Emailencodingkey = 'UTF-8',
Lastname = 'user_lastname',
Languagelocalekey = 'en_US',
Localesidkey = 'en_US',
Profileid = pf.Id,
Timezonesidkey = 'America/Los_Angeles',
Username = Math.random() + 'test#testuser.com',
CompanyName = 'the company',
UserRoleId='00E28000000zqCy'
);
insert usr;
string templateText = '<messaging:emailTemplate subject="{!relatedTo.Name}" recipientType="User" relatedToType="Custom_Object__c"><messaging:htmlEmailBody ><ul><li>test content</li></ul></messaging:htmlEmailBody></messaging:emailTemplate>';
EmailTemplate template = new EmailTemplate(DeveloperName = 'TestEmailVFTemplate', TemplateType= 'Visualforce', FolderId = UserInfo.getUserId(),
Name = 'TestEmailVFTemplate',
IsActive = true);
template.Markup=templateText;
System.runAs(usr){
insert template;
}
}

Unable to send attachment - Salesforce Docusign API

I am trying to send attachment (record has one attachment) in opportunity record via Apex and Docusign "CreateAndSendEnvelope" API.
But I am getting this error "The DocuSign EnvelopeId:Exception - System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: An Error Occurred during anchor tag processing. Invalid document faultcode=soap:Client faultactor=https://demo.docusign.net/api/3.0/dsapi.asmx"
Below is the piece of code used.
// Render the contract
System.debug('Rendering the contract');
PageReference pageRef = new PageReference('/apex/RenderContract');
pageRef.getParameters().put('id',contract.Id);
//Blob pdfBlob = pageRef.getContent();
Attachment att = [SELECT Id, Name, Body, ContentType FROM Attachment WHERE Parentid = :contract.Id LIMIT 1];
Blob pdfBlob = att.Body;
// Document
DocuSignAPI.Document document = new DocuSignAPI.Document();
document.ID = 1;
document.pdfBytes = EncodingUtil.base64Encode(pdfBlob);
document.Name = 'Contract';
document.FileExtension = 'pdf';
envelope.Documents = new DocuSignAPI.ArrayOfDocument();
envelope.Documents.Document = new DocuSignAPI.Document[1];
envelope.Documents.Document[0] = document;
// Recipient
System.debug('getting the contact');
Contact contact = [SELECT email, FirstName, LastName
from Contact where id = :contract.CustomerSignedId];
DocuSignAPI.Recipient recipient = new DocuSignAPI.Recipient();
recipient.ID = 1;
recipient.Type_x = 'Signer';
recipient.RoutingOrder = 1;
recipient.Email = contact.Email;
recipient.UserName = contact.FirstName + ' ' + contact.LastName;
// This setting seems required or you see the error:
// "The string '' is not a valid Boolean value.
// at System.Xml.XmlConvert.ToBoolean(String s)"
recipient.RequireIDLookup = false;
envelope.Recipients = new DocuSignAPI.ArrayOfRecipient();
envelope.Recipients.Recipient = new DocuSignAPI.Recipient[1];
envelope.Recipients.Recipient[0] = recipient;
// Tab
DocuSignAPI.Tab tab1 = new DocuSignAPI.Tab();
tab1.Type_x = 'SignHere';
tab1.RecipientID = 1;
tab1.DocumentID = 1;
tab1.AnchorTabItem = new DocuSignAPI.AnchorTab();
tab1.AnchorTabItem.AnchorTabString = 'By:';
DocuSignAPI.Tab tab2 = new DocuSignAPI.Tab();
tab2.Type_x = 'DateSigned';
tab2.RecipientID = 1;
tab2.DocumentID = 1;
tab2.AnchorTabItem = new DocuSignAPI.AnchorTab();
tab2.AnchorTabItem.AnchorTabString = 'Date Signed:';
envelope.Tabs = new DocuSignAPI.ArrayOfTab();
envelope.Tabs.Tab = new DocuSignAPI.Tab[2];
envelope.Tabs.Tab[0] = tab1;
envelope.Tabs.Tab[1] = tab2;
System.debug('Calling the API');
try {
DocuSignAPI.EnvelopeStatus es
= dsApiSend.CreateAndSendEnvelope(envelope);
envelopeId = es.EnvelopeID;
} catch ( CalloutException e) {
System.debug('Exception - ' + e );
envelopeId = 'Exception - ' + e;
}
Any ideas how to overcome this error?
Thanks.
The Original Poster's (OP's) comment is
it worked fine on rendering the whole record to pdf...but now i tried sending attachments only instead of whole record.. i started to get this error.
So my guess is that the envelope request has a document problem.
Best way to debug: see what is being sent to the DocuSign platform.
Try the beta API logger or the regular logger. Then add the log to your question by editing your question.
This problem came across me with same error .
" An Error Occurred during anchor tag processing. Invalid document faultcode=soap:Client faultactor=https://demo.docusign.net/api/3.0/dsapi.asmx "
you need to replace anchor tab string with desired string given in your attached document where signature is required.
Replace :
tab1.AnchorTabItem.AnchorTabString = 'By:';
tab2.AnchorTabItem.AnchorTabString = 'Date Signed:';
To :
tab1.AnchorTabItem.AnchorTabString = 'Signature label in your document';
tab2.AnchorTabItem.AnchorTabString = 'Signature label in your document';

url sharepoint list camlquery

I'm trying to collect my url and the description of the url stored in a column of a list from sharepoint and i don't know how to collect the URL value.
This is my code :
var queryResultSaleListItems = clientContext.LoadQuery(listData);
clientContext.ExecuteQuery();
//Read the Data into the Object
var TipsList = from Tips in queryResultSaleListItems
select Tips;
ObservableCollection<Tips> colTips = new ObservableCollection<Tips>();
//Read Every List Item and Display Data into the DataGrid
foreach (SPSClient.ListItem item in TipsList)
{
var tips = new Tips();
tips.TitleTip = item.FieldValues.Values.ElementAt(1).ToString();
tips.App = item.FieldValues.Values.ElementAt(4).ToString();
//should collect the url
tips.URL = item.FieldValues.Values.ElementAt(5).ToString();
//should collect the description of the url
tips.URLdesc = item.FieldValues.Values.ElementAt(5).ToString();
colTips.Add(tips);
}
ListboxTips.DataContext = colTips;
In my expression its >
((Microsoft.SharePoint.Client.FieldUrlValue)(item.FieldValues.Values.ElementAt(5))).Url
((Microsoft.SharePoint.Client.FieldUrlValue)(item.FieldValues.Values.ElementAt(5))).Description
Thanks for your help,
Use FieldUrlValue for getting hyperlink field in Client Object Model.
Use Following Code:
string server = "siteURL";
var ctx = new ClientContext(server);
var web = ctx.Web;
var list = web.Lists.GetByTitle("CustomList");
var listItemCollection = list.GetItems(CamlQuery.CreateAllItemsQuery());
ctx.Load(listItemCollection);
ctx.ExecuteQuery();
foreach (Microsoft.SharePoint.Client.ListItem listItem in listItemCollection)
{
string acturlURL = ((FieldUrlValue)(listItem["URL"])).Url.ToString(); // get the Hyperlink field URL value
string actdesc = ((FieldUrlValue)(listItem["URL"])).Description.ToString(); // get the Hyperlink field Description value
}

Resources