How to map Signature field into Word template | CloudFronts

How to map Signature field into Word template

Introduction :

As we know , signature field with pen control can not be mapped directly into word template.

This blog will explain how to map  signature field into word template.

Implementation :

Steps to Add Signature Field

Step 1 :  Create signature Field with data type multiple line of text and maximum length 15000

 

Step 2:  Then in the field properties -> control -> select Pen Control and Add.

In word template ,signature field will map as a text field which contains base 64 separated by comma.

As shown below.

Steps for resolution:

Step 1 : To map signature field in picture format in word template , create new field signature text with data type multiple line of text and maximum length 1048576.

 

 

Step 2 : Write plugin. Plugin will trigger on create of record and update of signature field.

Plugin Explanation : Plugin will retrieve the value of signature and separate  ” data:image/png;base64 ” string followed by “,” (comma) and save remaining text in newly created signature text field.

 

Plugin Registration:

  1. Register a plugin on create and update of account entity     2.Plugin Code
void SignatureUpdate(Entity account)
{
tracingService.Trace("postmsg : " + account);

string signaturetext = string.Empty;
string attributeToUpdate = string.Empty;
Entity AccountUpdate = null;
try
{
AccountUpdate = new Entity();

AccountUpdate.Id = account.Id;
AccountUpdate.LogicalName = account.LogicalName;
if (account.Contains("new_signature") && account["new_signature"] != null)
{
signaturetext = account.GetAttributeValue<string>("new_signature");
attributeToUpdate = "new_signaturetext";
AccountUpdate = ProcessSignature(signaturetext, AccountUpdate, attributeToUpdate);

}
service.Update(AccountUpdate);
}
catch (Exception)
{
throw;
}
}
public Entity ProcessSignature(string signaturetext, Entity Account, string attribute)
{
//to split base64 and remaining text
string[] substring = signaturetext.Split(',');
Account[attribute] = substring[1];
return Account;
}

3. build the code and update assembly and trigger a plugin

And upload this template .

Result :


Share Story :

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close