Take Signature in CRM Application


Hello, many times we’ll get requirement to add Signature into CRM form and put it into some reports for some Documents. You can export that Signature into Reports as well as in Word templates.

So here is your answer...

Create Web Resource of HTML:


Add below code to it:
--------------------------------------------------------------------------------------------------------------------------
<html><head>
      <title>Signature</title>
      <script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.1.min.js"></script>
      <script src="new_jSignature.min"></script>
  <meta><meta><meta><meta><meta><meta><meta><meta></head>
      <body style="word-wrap: break-word;">
          <img id="sigImage" alt="This is an image of the persons signature." style="display:none">
         <div id="sigPanel" style="display: none; font-family: undefined;">
             <div id="signature"></div>
             <button id="clear">Clear</button>
         </div>
         <script type="text/javascript">
             $(function () {
                 var sigImage = $("#sigImage");
                 var sigPanel = $("#sigPanel");
                 var sig = $("#signature");

                 var Xrm = window.parent.Xrm;
                 var sigBase64Attribute = Xrm.Page.getAttribute("new_signature");  // give name as your multiline text box
//replace this with your hidden "multiple lines of text" field with a max length of 1,048,576
                 var sigBase64Value = sigBase64Attribute.getValue();

                 sig.bind("change", function (e) {
                     sigBase64Attribute.setValue(sig.jSignature("getData"));
                 });

                 if (sigBase64Value != null) {
                     sigImage.css("display", "inline");
                     sigImage.attr("src", sigBase64Value);
                 } else {
                     sigPanel.css("display", "inline");
                     sig.jSignature();
                     $("#clear").click(function() {
                         sig.jSignature("clear");
                     });
                 }
             });
         </script>
    
 </body></html>
--------------------------------------------------------------------------------------------------------------------------
Add Source Javascript from http://willowsystems.github.io/jSignature/#/about/ for JSignature and add into form.
--------------------------------------------------------------------------------------------------------------------------
Add that Web Resource to the form.


--------------------------------------------------------------------------------------------------------------------------
Make one Multiline text box. Named it “new_signature”. Give size more than 15,000(1,048,576).
The Signature will be stored in Base64. To export into word template, you have to remove “data:image/png;base64,” string of the multiline textbox. So you have to store in another multiline textbox after removing this string. And then open that control in word template as picture.
To remove string, you have to add Javascript:

new_signature: main textbox
new_signature_word: after removing
--------------------------------------------------------------------------------------------------------------------------
function code_for_word() {
   var new_signature = Xrm.Page.getAttribute("new_signature").getValue();
   var signature_word=new_signature.split(',')[1];
   Xrm.Page.getAttribute("new_signature_word").setValue(signature_word);
   }
Don’t forget to “Yes” to Use legacy form rendering in System Setting.
Now, here you go…….. Whatever you will do Signature, relevant Base64 will convert and will store in both the multi-line textbox.
--------------------------------------------------------------------------------------------------------------------------
To export in report:
Add Image property in report
In Expression write below code:
--------------------------------------------------------------------------------------------------------------------------
=IIF(NOT IsNothing(Fields!new_signature.Value),Fields!new_signature.Value.ToString().Split(“,”).GetValue(1),””)




Preview:


Do let us know if this is useful for you.....

Till then... Happy CRM Surfing...

Comments

Popular posts from this blog

Copy Subgrid data from one entity to another entity

Explaining Attachment Management Solution for Dynamics CRM/365 Online