Resources for IT Professionals > Dynamics Forums > CRM Development > Add reply button in history window for emails in crm 4.0
Ask a questionAsk a question
 

AnswerAdd reply button in history window for emails in crm 4.0

Answers

All Replies

  • Tuesday, October 27, 2009 3:25 PMRichard M. Riddle Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    This is the correct forum for your post.

    Paste this snippet into your isv config file:

            <Entity name="activitypointer">
                      <Grid>
    	            <MenuBar>
    	              <Buttons>
    	                <Button JavaScript="var a = document.all['crmGrid'].InnerGrid.SelectedRecords; if(a.length &gt; 1){alert('only one record, please');} else {if(a[0][1] != 4202){alert('the selected record is not an email');} else {alert(a[0][0]);}}">
    	                  <Titles>
    	                    <Title LCID="1033" Text="Get GUIDS" />
    	                  </Titles>
    	                  <ToolTips>
    	                    <ToolTip LCID="1033" Text="Get GUIDS for selected records" />
    	                  </ToolTips>
    	                </Button>
    	              </Buttons>
    	            </MenuBar>
              </Grid>
            </Entity>
    
    

    This will provide you a way to select one email and do something with it.  This is not the complete solution though, you still need to add some qeuerystring values which I can't figure out how to retrieve.  To determine these query string values, open an email, click Reply or Reply All, and then hit Ctrl + N on the new window to see the address bar.

    • Marked As Answer byCRM_User Wednesday, October 28, 2009 2:13 PM
    • Unmarked As Answer byCRM_User Saturday, October 31, 2009 6:12 AM
    •  
  • Wednesday, October 28, 2009 2:13 PMCRM_User Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hey Richard, thanks very much. The button is placed at the place i want :). I will work further on query string and will update accordingly.

    Thanks very much again.
  • Friday, October 30, 2009 4:47 PMCRM_User Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi All,

    The query string to Email page is some what like this...

    https://domain/activities/email/edit.aspx?_InReplyToId=%7bE0BD4F9B-CBC3-DE11-87D6-000E7F7D6356%7d&crmFormSubmitMode=8&CRMWRPCToken=rAMpOsCBEd6H1gAOf31jVniC8waNZrWpGFfHdPD7ajhWRKSPIf43HQruOoNSM5oW&CRMWRPCTokenTimeStamp=633925135374086808

    How can i get the values of
    crmFormSubmitMode
    CRMWRPCToken
    CRMWRPCTokenTimeStamp

    in History/Activity window. And how i can open email window from History/Activity window. Is it simple window.open?

    Thanks
  • Monday, November 02, 2009 9:51 AMCRM_User Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,

    Can any one suggest me how to get the values for

    crmFormSubmitMode
    CRMWRPCToken
    CRMWRPCTokenTimeStamp

    on History window.

    I know these fields are in form named crmFormSubmit but I am unable to get the values for these with javascript in ISV.Config. Cna any one guide me on this.

    Thanks
  • Monday, November 02, 2009 3:17 PMCRM_User Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi All,

    Can any one guide me on this.

    Thanks
  • Monday, November 02, 2009 9:10 PMRichard M. Riddle Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    The crmFormSubmitMode seems to be 8 every time.  I don't know if there are other crmFormSubmitMode values, but 8 works for me.  The CRMWRPCTokenTimeStamp is now.ticks(), I believe.

    The hard one is the CRMWRPCToken.  This is a base 64 string, but I can't determine the encoding nor can I get anything readable out of it.  Part of it has to do with the id field in the CRMkey table in the CRM config database, but again, I can't make heads or tails out of most of it.

    Looking at the http traffic and the source of the email page, the full url of the reply to page is known when the email page is served, which to me means the values are generated by the asp.net code and not calculated using javascript.  A search of the javascript files on the CRM server reveals no file with the text frombase64string, which is the error I get when attempting to use an invalid token.

    What all this means is you have two ways to direct the user to the correct page with one click.
    1.  You can open the email with the button and use javascript to execute the reply/replyall/forward function and then handle closing the email window.  Depending on your page load times, this could be a really bad idea.

    2.  You can create a custom page which uses a WebClient to do a screen scrape of sorts of the email window and then redirects the client to the new page.  This solution is cleaner but does require custom .net code on the server.
  • Tuesday, November 03, 2009 8:50 AMCRM_User Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Oh, both the solutions seem to be very tricky :(. I have further analyzed the windows History/Actvities and found that the the value for CRMWRPCToken is present in a hidden field under the form crmFormSubmit. Cant we get that value in Javascript placed in ISV.Config XML file?

    And also verified that now.ticks() is also not working. I have placed in an alert and getting the value as null.

  • Tuesday, November 03, 2009 2:08 PMRichard M. Riddle Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    There is no exact Javascript representation for ticks; it's a .net thing.  This link shows how to calculate .net ticks in javascript:  http://codemonkey.joeuser.com/article/308527.

    I don't know of any way to access hidden fields on a form without rendering that page, either into memory or into the browser.  Research javascript screen scrapers and you may find something useful.

  • Tuesday, November 03, 2009 3:00 PMCRM_User Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Richard, can you please tell me where the Javascript written in the ISV Config file be stored. I mean we are able to access the 'crmGrid' which is not seen in the view source and we are not able to access the control which is seen in view source (CRMWRPCToken). Can you point me to any article that explains the way the CRM forms are designed (mentioning the controls on the form, frames, etc). Probably this will help me to dig further.

    Thanks

  • Tuesday, November 03, 2009 4:10 PMRichard M. Riddle Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I haven't found any articles that talk about the html behind each CRM page because using the raw html is unsupported.  However, you can use the developer toolbar to navigate the DOM of the page, which should give you access to the CRMWRPCToken on the entity, but there's no telling whether this token will be valid for sending email.

    Search for forum posts about hiding form buttons and most of those will have examples of how to navigate the DOM of the crm Form.

  • Wednesday, November 04, 2009 4:41 AMCRM_User Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Well, the CRMWRPCToken given in the hidden field on History/Actvities window is different from the one that is passed when you click on the Reply button on email window. This is really becoming very tricky.

    Can we get these values by sending Ajax request to the server? Are you aware of any method that will return this?
  • Friday, November 06, 2009 5:17 PMRichard M. Riddle Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    The only method I have found to get the Token is to use the .Net webclient to return the page as a string and parse it.

  • Saturday, November 07, 2009 11:20 AMCRM_User Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Richrad, could you please elaborate this or point to article which explains your point. I will try with this.
  • Tuesday, November 10, 2009 4:12 PMRichard M. Riddle Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Create a custom html page on your CRM server.  Use the sample code here http://msdn.microsoft.com/en-us/library/xz398a3f(VS.80).aspx to retrieve the page as a string.  Once you have your custom page as a string and are able to get a feel for how to parse it, point your webclient.downloaddata to a CRM email page.  The good thing about using this method is you already have the url of the reply/replyall/forward pages in the code, so you don't have to worry about extracting the token, just find the url and redirect to it.