GetArgs and reading the URL

I am trying to add a parameter to the URL. I am able to do this if I call my page from a button. However, I am calling my page through workflow and it does not appear to be working and I cannot figure out why.

I have the following URL

sagecrm/.../LeaseEmail.asp

It was generated as follows from workflow. The type is a transition rule and the custom file name is CHS/LeaseEmail.asp?type=Lease (type=Lease) being the parameter I am trying to pass.

I put the following script in custom content..

<script>
function Toby()
{
var EmailType = crm.getArg("type");
if(EmailType == "Lease")
{
alert("It's there.");
}
else
{
alert("It's not.")
}
}

crm.ready(function()
{
Toby();
});
</script>

When I hit the workflow item, I get a message...It's not.

I cannot see what I am doing wrong. Any assistance would be greatly appreciated! Thank you!

  • 0

    If you go to the console and run:

    crm.getArg("type");

    Then presumably you are getting 'Lease' returned?

    If so, then it would seem your code is not executing at the correct point, if you are redirecting, could it be running before the redirect?

  • 0

    Huh? Someone mentioned my name.

  • 0

    >>Does crm have a way that I could put a function in custom content to see all the values returned and display it on the screen?


    Yes: http://help.sagecrm.com/js-api/classes/crm.html#method_infoMessage

    Or you can write it to an error string:

    errorstr = "This is an error string";

    >>do you know what J= represents in the URL


    As ever, Jeff explains it here:

    https://community.sagecrm.com/partner_community/b/hints_tips_and_tricks/archive/2008/02/17/is-this-the-final-word-on-what-the-url-variables-mean.aspx

    Custom Jump Values
    If we consider the following URL

    localhost/.../userlicensekeylist.asp

    • J is the target page for the URL
    • F is the original context (or page)
    • E is the target Entity
    • T is the default tabgroup


    >>I added the param to the page with....CHS/LeaseEmail.asp?type=Lease Therefore, it should be there when the page is loaded. Correct?

    I cannot replicate what you have going on. If I mimic what you have done, I get the type in the URL and the function you use here finds it and gives me the correct alert. If you change what you are looking for to anything other than your 'type=lease' does it work? Or does it do the same?

  • 0

    Weird I cannot replicate doing the same as you, but seems like it is parsing something like:

    But you can get the SID out of it, so I am probably just talking crap.

    What I would be tempted to do first is set up an ASP page that just redirects to your page using:

    Response.redirect(CRM.url("CHS/LeaseEmail.asp")+"&type=Lease"

    That will then put your stuff at the end of the URL which may mean it is visible.

    Alternately, park the client side api for this and use something like:

    window.location.href.indexOf("Lease") > -1


    Meaning if 'Lease' is found in the URL then it will give an index of greater than -1, so you know it is there and can initiate what you need.

  • 0

    Toby...

    Thank you for your response. Yes, if I go to the console and run...crm.getArg("type"); It does return "Lease".

    Interesting....

    I added the param to the page with....CHS/LeaseEmail.asp?type=Lease. Therefore, it should be there when the page is loaded. Correct?

    I ran my function with crm.ready which should execute once the page is loaded. When the page is loaded, that param is there.

    Therefore, I am a bit baffled.

    Does crm have a way that I could put a function in custom content to see all the values returned and display it on the screen?

    Also, do you know what J= represents in the URL. It appears to be identifying my page again without the param.

    I will look in the page code and see if there is a possible redirect...if so, maybe I can move my function into the actual page code...just not sure where to put it.

    Any assistance you could provide would be greatly appreciated! Thank you!!

  • 0

    Jeff...lol. Just trying to tap into your immense brain through your published articles! :-)

    Thanks Toby! I will check out these articles.

    In regards to your question about changing what I am looking for, type appears to be the only thing that it cannot find. I had used some JS to put an alert on the screen to return all the values in the URL and it started at the SID...right after the type.

    Knowing that this may be due to some kind of page redirect, I think I might be able to solve my issue by moving my function to the asp page. I think if I move it into the "if in Edit mode" section. It should work. Thoughts?

    Just not sure where to put it in that section...this is the code...

    if (CRM.Mode

    var Container=CRM.GetBlock("Container")

    var SpecList = eWare.GetBlock("Content");

    var content='';

    content+=""

    content+=""

    content+=""

    content+=""

    content+=""

    content+=""

    content+=""

    SpecList.contents =content;

    Container.AddBlock(SpecList)

    //Add a cancel button to the container

    Container.AddButton(CRM.Button("Cancel","Cancel.gif",CRM.URL("200")));

    CRM.AddContent(Container.Execute());

    Response.Write("")

    Response.Write(CRM.GetPage())

    Any assistance you could provide would be greatly appreciated!!