locked
Capture image (signature) to notes as attachment RRS feed

  • Question

  • Hi All,
    Can anyone give me a clue on this development I would like:

    Background: I created a "Sample" entity related to a contact (and product). When I drop off a sample I would like to capture a signature from the customer.

    Idea: I imagine this:
    1) Open the contact and create a new sample entity (fill in the fields and product)
    2) Hit a "Signature Buttom" and mspaint.exe is opened in full screen (i would like filename to become "date"+"full name".
    3) When the customer has signed inside Paint (on my tablet) I hit close and save the object as a .jpg file
    4) The saved .jpg object is attached in a note inside the sample entity

    Questions:
    1) Is it possible to create this as javascript only (on the client side)
    2) Any ideas/code examples to build the above functionality
    3) Would it work off-line (I need this)

     


    crm i danmark
    Thursday, July 23, 2009 8:25 PM

Answers

  • change the function name inside the onload event handler

    from

    function CreateCustomerSignature(customerName)
    {

    }

    to

    CreateCustomerSignature = function(customerName)
    {

    }


    Blog: http://mscrm4ever.blogspot.com/ * Website: http://gicrm.upsite.co.il/
    Friday, July 24, 2009 1:09 PM

All replies

  • If you want it to work offline as well as online. I suggest you use outlook  client for CRM. Then can  write an outlook add-on to automate a lot of the process without the need to use a lot of javascript.

    Hope this helps.
    • Proposed as answer by Wael HamzeMVP Friday, July 24, 2009 10:31 AM
    Friday, July 24, 2009 7:41 AM
  • Hi københavn,

    Answers
    1. No. Not Possible at all.
    2. If it is not possible how would I answer this?
    3. You need a seperate WinForms Application[Maybe ClickOnce] to get this task done.

    You might want to explore VBScript/JScript, but with that lot of security issues will come in to the picture, best thing in my knowledge is to go for a WinForms Application.
    Regards,
    Chinmay
    http://metrix.blogspot.com
    • Proposed as answer by Chinmay Patel Friday, July 24, 2009 9:02 AM
    Friday, July 24, 2009 8:59 AM
  • The following script creates and opens a bitmap file in a dedicated signature folder which you can create in your laptop. Make sure you are able to run ActiveX controls in your browser otherwise IE will ask for permissions each time you press the button.

     

    After the customer signs the bmp navigate to the sample CRM window and attach the file (using the notes tab or upload button) from the signature folder.

     

    function OnCrmPageLoad()

    {

                  /* your button should implement this line */
                  
    if (crmForm.fullname.DataValue != null)

                   {

                                  CreateCustomerSignature(crmForm.fullname.DataValue)

                   }

    }

     

    function CreateCustomerSignature(customerName)

    {

                   /* Create Bitmap */

                   var custSigBmp  = new ActiveXObject("scripting.filesystemobject");

                   /* Define bmp date part */

                   var currentDate = new Date();

                   var custSigDate = currentDate.getDate() + "" + (currentDate.gebtMonth() + 1) + currentDate.getFullYear();

                   /* Signatures folder */

                   var custSigFolder = "C:\\Signatures\\";

                   /* Define customer bmp name - can be any valid file name format */

                   var custSigBmpName = custSigDate + " - " + customerName + ".bmp";

                   /* Full path to customer bmp */

                   var custSigBmpFullPath = custSigFolder + custSigBmpName;

                   /* Create the file on disk */         

                                  custSigBmp.CreateTextFile(custSigBmpFullPath,true);

                  

                   /* Open Bitmap */

                   var mspaint = new ActiveXObject("wscript.shell");

                   /* mspaint full path */

                   var mspaintFullPath = "C:\\windows\\system32\\mspaint.exe";    

                   /* Open the customer bitmap */

                   var command = mspaintFullPath + " \"" + custSigBmpFullPath + "\"";

                         mspaint.run(command);

    }

     

    OnCrmPageLoad();


    Blog: http://mscrm4ever.blogspot.com/ * Website: http://gicrm.upsite.co.il/
    Friday, July 24, 2009 11:02 AM
  • Yupp.. JScript/VBScript in action.. pretty neat!!! How you plan to upload it to notes though? :-/
    Regards,
    Chinmay
    http://metrix.blogspot.com
    Friday, July 24, 2009 11:11 AM
  • Assuming the sample entity has notes (annotations) the easiest path would be to save the signature as annotation manually.


    Blog: http://mscrm4ever.blogspot.com/ * Website: http://gicrm.upsite.co.il/
    Friday, July 24, 2009 11:20 AM
  • Exactly... Thanks.
    Regards,
    Chinmay
    http://metrix.blogspot.com
    Friday, July 24, 2009 11:35 AM
  • Dear Adi,
    Thanks so much for your suggestion - I like the idea, and I think I can live with manually uploading the signature to annotations.

    But I try to make it work without luck ...

    This is what I added to the contact button:
           <Entity name="contact">
              <!-- The Contact Tool Bar -->
              <ToolBar ValidForCreate="0" ValidForUpdate="1">
                <Button Icon="/_imgs/ico_18_debug.gif" JavaScript="if (crmForm.lastname.DataValue != null) { CreateCustomerSignature(crmForm.lastname.DataValue) };">
                  <Titles>
                    <Title LCID="1033" Text="Signature" />
                  </Titles>
                  <ToolTips>
                    <ToolTip LCID="1033" Text="Create new signature in c:\signatures for upload" />
                  </ToolTips>
                </Button>
              </ToolBar>
            </Entity>

    And this is the code I added the contact onload form:
    function CreateCustomerSignature(customerName)

    {

                   /* Create Bitmap */

                   var custSigBmp  = new ActiveXObject("scripting.filesystemobject");

                   /* Define bmp date part */

                   var currentDate = new Date();

                   var custSigDate = currentDate.getDate() + "" + (currentDate.gebtMonth() + 1) + currentDate.getFullYear();

                   /* Signatures folder */

                   var custSigFolder = "C:\\Signatures\\";

                   /* Define customer bmp name - can be any valid file name format */

                   var custSigBmpName = custSigDate + " - " + customerName + ".bmp";

                   /* Full path to customer bmp */

                   var custSigBmpFullPath = custSigFolder + custSigBmpName;

                   /* Create the file on disk */         

                                  custSigBmp.CreateTextFile(custSigBmpFullPath,true);

                  

                   /* Open Bitmap */

                   var mspaint = new ActiveXObject("wscript.shell");

                   /* mspaint full path */

                   var mspaintFullPath = "C:\\windows\\system32\\mspaint.exe";    

                   /* Open the customer bitmap */

                   var command = mspaintFullPath + " \"" + custSigBmpFullPath + "\"";

                         mspaint.run(command);

    }

    When I press my button I only get a "Error on page" in the status bar.

    Any clues?

    But thanks for the ideas so far!!!!

    /Henrik


    crm i danmark
    Friday, July 24, 2009 1:00 PM
  • change the function name inside the onload event handler

    from

    function CreateCustomerSignature(customerName)
    {

    }

    to

    CreateCustomerSignature = function(customerName)
    {

    }


    Blog: http://mscrm4ever.blogspot.com/ * Website: http://gicrm.upsite.co.il/
    Friday, July 24, 2009 1:09 PM