locked
Displaying URL to case RRS feed

  • Question

  • Hello,

    I'm using this accelerator:

    http://crmaccelerators.codeplex.com/releases/view/26691

    Works great for sending URLs via email.  But this is what I'm trying to do - get the URL of a case, and include it on a form field for another case.  So within one case, you can click on a link to details of a previous case.

    I've tried it with an attribute of varchar, or varchar/URL, neither work.  URL displays as a hyperlink, but they boh include tags ("<a href=") that won't work in the browser.

    What am I missing?

    Cheers--gg

    Friday, July 2, 2010 3:50 PM

Answers

  • You need to create your own custom workflow action for this...just change following lines..

    Currently -

    // Get the record id from the context
    Guid id = ctx.PrimaryEntityId;
    				
    // Configure the Url and pass back to the output parameter
    string fullUrl = string.Format(this.Url,id);
    this.ReturnUrl = string.Format(@"<a href=""{0}"">{1}</a>", fullUrl, this.UrlText);

    new change

    // Get the record id from the context
    Guid id = ctx.PrimaryEntityId;
    				
    // Configure the Url and pass back to the output parameter
    string fullUrl = string.Format(this.Url,id);
    this.ReturnUrl = string.Format(@"{0}">{1}</a>", fullUrl, this.UrlText);
    
    • Marked as answer by geeky girly Wednesday, July 7, 2010 9:54 PM
    Saturday, July 3, 2010 7:27 PM
    Answerer
  • Hi,

    I have shared full code file (class file) at  http://drop.io/gatlbso/asset/mscrmurlgenerator-cs , download this file and use it in your application and see if this works..

     

     

    Wednesday, July 7, 2010 9:11 AM
    Answerer

All replies

  • You need to create your own custom workflow action for this...just change following lines..

    Currently -

    // Get the record id from the context
    Guid id = ctx.PrimaryEntityId;
    				
    // Configure the Url and pass back to the output parameter
    string fullUrl = string.Format(this.Url,id);
    this.ReturnUrl = string.Format(@"<a href=""{0}"">{1}</a>", fullUrl, this.UrlText);

    new change

    // Get the record id from the context
    Guid id = ctx.PrimaryEntityId;
    				
    // Configure the Url and pass back to the output parameter
    string fullUrl = string.Format(this.Url,id);
    this.ReturnUrl = string.Format(@"{0}">{1}</a>", fullUrl, this.UrlText);
    
    • Marked as answer by geeky girly Wednesday, July 7, 2010 9:54 PM
    Saturday, July 3, 2010 7:27 PM
    Answerer
  • Thank you.  I'm afraid I'm not familiar with writing a custom workflow - could you help with additional syntax?  I'm somewhat familiar with the SDK and could (I think) write this, would it be something like this?  I'm obviously missing something, further pointer in the right direction would be very helpful.  Thanks!!  gg

    using

     

    System;

    using

     

    System.Collections.Generic;

    using

     

    System.Text;

    namespace

     

    HyperlinkWorkflow

    {

     

    public class HLWF

    {

     

    public void Execute(IPluginExecutionContext context)

    {

     

    // Get the record id from the context

     

    Guid id = ctx.PrimaryEntityId;

     

     

    // Configure the Url and pass back to the output parameter

     

    string fullUrl = string.Format(this.Url,id);

     

    this.ReturnUrl = string.Format(@"{0}">{1}</a>", fullUrl, this.UrlText);

    }

    }

    }

    Monday, July 5, 2010 8:44 PM
  • I think what you are looking for is URL so if you do following line then it will be fine..replace following two line in existing code as mentioned below

    string fullUrl = string.Format(this.Url,id);

     

    this.ReturnUrl = fullUrl;

     

    Also check out following article on how to devlope custom workflow activity in CRM.

    http://www.stunnware.com/crm2/topic.aspx?id=CustomWorkflowActivity

     

    Hope this helps..

     

    Monday, July 5, 2010 9:46 PM
    Answerer
  • Ok, closer - based on the website you sent, I set this up as a workflow library.  My code is below.  Error messages are:

    Error 1 The name 'ctx' does not exist in the current context U:\CRM\VS2008\Projects\GetHyperLink\GetHyperLink\GetHyperlinkActivity.cs 23 23 GetHyperLink
    Error 2 'GetHyperLinkLibrary.GetHyperlinkActivity' does not contain a definition for 'Url' and no extension method 'Url' accepting a first argument of type 'GetHyperLinkLibrary.GetHyperlinkActivity' could be found (are you missing a using directive or an assembly reference?) U:\CRM\VS2008\Projects\GetHyperLink\GetHyperLink\GetHyperlinkActivity.cs 24 49 GetHyperLink
    Error 3 'GetHyperLinkLibrary.GetHyperlinkActivity' does not contain a definition for 'ReturnUrl' and no extension method 'ReturnUrl' accepting a first argument of type 'GetHyperLinkLibrary.GetHyperlinkActivity' could be found (are you missing a using directive or an assembly reference?) U:\CRM\VS2008\Projects\GetHyperLink\GetHyperLink\GetHyperlinkActivity.cs 25 18 GetHyperLink

    I have added references to Microsoft.Crm.Sdk.dll and Microsoft.Crm.SdkTypeProxy.dll.

    Thanks for all the help!

    --

    using

     

    System;

    using

     

    System.ComponentModel;

    using

     

    System.ComponentModel.Design;

    using

     

    System.Collections;

    using

     

    System.Drawing;

    using

     

    System.Workflow.ComponentModel.Compiler;

    using

     

    System.Workflow.ComponentModel.Serialization;

    using

     

    System.Workflow.ComponentModel;

    using

     

    System.Workflow.ComponentModel.Design;

    using

     

    System.Workflow.Runtime;

    using

     

    System.Workflow.Activities;

    using

     

    System.Workflow.Activities.Rules;

    using

     

    Microsoft.Crm.Sdk;

    using

     

    Microsoft.Crm.SdkTypeProxy;

    using

     

    Microsoft.Crm.Workflow;

    namespace

     

    GetHyperLinkLibrary

    {

     

    public partial class GetHyperlinkActivity: SequenceActivity

    {

     

    public GetHyperlinkActivity()

    {

     

    Guid id = ctx.PrimaryEntityId;

     

    string fullUrl = string.Format(this.Url, id);

     

    this.ReturnUrl = fullUrl;

    }

    }

    }

    Tuesday, July 6, 2010 12:07 AM
  • Hi,

    ctx.PrimaryEntityId ???

    Is it your full code ??? I hope you just pasted only some part of your code ??, so if you can paste full code then that will help !!!


    Mahain
    Tuesday, July 6, 2010 6:19 AM
    Moderator
  • Hi,

    you are missing first two lines as follows, add them and it will start working ..

    //Get context 
      IContextService contextService = (IContextService)executionContext.GetService(typeof(IContextService)); 
      IWorkflowContext ctx = contextService.Context;
      
      // Get the record id from the context
      Guid id = ctx.PrimaryEntityId;
    
    
    
    
    Hope this helps..
    Tuesday, July 6, 2010 9:26 AM
    Answerer
  • Still errors, sorry I'm not better at troubleshooting this???

    Code is:

    namespace

     

    GetHyperLinkLibrary

    {

     

    public partial class GetHyperlinkActivity: SequenceActivity

    {

     

    public GetHyperlinkActivity()

    {

     

    IContextService contextService = (IContextService)executionContext.GetService(typeof(IContextService));

     

    IWorkflowContext ctx = contextService.Context;

     

    Guid id = ctx.PrimaryEntityId;

     

    string fullUrl = string.Format(this.Url, id);

     

    this.ReturnUrl = fullUrl;

    }

    }

    }

    errors are: 

    Error 1 The name 'executionContext' does not exist in the current context u:\CRM\VS2008\Projects\GetHyperLink\GetHyperLink\GetHyperlinkActivity.cs 23 63 
    Error 2 'GetHyperLinkLibrary.GetHyperlinkActivity' does not contain a definition for 'Url' and no extension method 'Url' accepting a first argument of type 'GetHyperLinkLibrary.GetHyperlinkActivity' could be found (are you missing a using directive or an assembly reference?) u:\CRM\VS2008\Projects\GetHyperLink\GetHyperLink\GetHyperlinkActivity.cs 27 49 
    Error 3 'GetHyperLinkLibrary.GetHyperlinkActivity' does not contain a definition for 'ReturnUrl' and no extension method 'ReturnUrl' accepting a first argument of type 'GetHyperLinkLibrary.GetHyperlinkActivity' could be found (are you missing a using directive or an assembly reference?) u:\CRM\VS2008\Projects\GetHyperLink\GetHyperLink\GetHyperlinkActivity.cs 28 18 
    Error 4 'ActivityLibrary1.GetHyperlinkActivity' does not contain a definition for 'Name' and no extension method 'Name' accepting a first argument of type 'ActivityLibrary1.GetHyperlinkActivity' could be found (are you missing a using directive or an assembly reference?) u:\CRM\VS2008\Projects\GetHyperLink\GetHyperLink\GetHyperlinkActivity.Designer.cs 28 9 

    Tuesday, July 6, 2010 4:38 PM
  • Hi,

    I have shared full code file (class file) at  http://drop.io/gatlbso/asset/mscrmurlgenerator-cs , download this file and use it in your application and see if this works..

     

     

    Wednesday, July 7, 2010 9:11 AM
    Answerer
  • MayankP--Thank you ~so~ much for all your help.  Between the code you were kind enough to provide, and the details on setting up a custom workflow, I am up and running. 

    Cheers!!

    gg

    Wednesday, July 7, 2010 9:54 PM