Handling URL’s in COM API part 1

By | January 7, 2011

Well, before starting off with the post I must say that this is the pure development content most probably in the interests of developers? This is the multipart series in which I will be explaining how to handle the URL’s to avoid navigation and other scripting issues in COM API development work. In this post I will be briefing an importance of passing parameters to the URL’s and how to read them in pages efficiently to avoid crashing issues.

I believe every developer developing the entity structures, ASP pages or even small scripts in CRM faces issues handling URL’s back and forth through pages. For example if we are creating a standard entity in CRM it must be a thumb rule, that if I click on the record link in the list in list page and move to summary page the previous state has to be the list page only. I.e. if I click back button or continue button it should take me back to the list page. Similar is the case of Summary page. When summary page goes to edit mode, it’s just a mode that changes so we don’t need to handle the URL’s in this case as explained, but still handle the several modes in the pages.

When we are developing the entities we must make sure that we are always passing the primary id of the entity in all pages; specifically when I move from list to summary and there onwards to any other page related to the summary. For example suppose we have entity called Contracts which is a child entity of CRM Company entity we may put the tab named Contracts under Company context.

Clicking this tab presents the list of Contracts linked to that particular company. Now we also need to keep track of the sub contracts related to these contracts then, we must have a separate tab to view them under Contracts context as shown below.

In this case it is very important to pass the company id as well as the contract id to Subcontracts tab also to manage them further. We can pass these id’s in URL’s we are creating through page like given below.

Code

eWare.URL(“Contracts/Subcontracts/ SubcontractSummary.asp”)+”&subc_companyid=”+pmCompanyId+”&subc_ContratId=”+ pmContractId+”&subc_subcid=”+pmSubContractId

Now why are we passing these parameters as we are using eWare.URL and we must be getting them in keys every time? It’s just to make sure that the next page loads based on these values and we must always have the values in hand before building that page further. For example in above case when I move to Subcontracts Summary page from anywhere I may be getting company id Key1 as we are using eWare.URL, then also I am sending the one in Comp_companyid just to make sure we always have it. Inside the summary page I can do checking as mentioned below.

Code

var pmCompanyId = “”;
pmCompanyId = new String(Request.QueryString(“Key1”))
if(pmCompanyId==”” pmCompanyId==”undefined”)
{
pmCompanyId = new String(Request.QueryString(“Key1”))
if(pmCompanyId==”” pmCompanyId==”undefined”) pmCompanyId=”0”;
}

I am making the id parameter zero when undefined to make sure whenever I pass it to query, query doesn’t crash out.
Now question is, how do I pass the two parameters through the record hyperlink in list? We already pass the record id like given below to build the summary page.

We can pass the comma separated parameters also to have them in next page. Suppose in above case we want to pass the company id, we must have a field in SubContracts table to store company id too like subc_companyid, then we can pass this value in above field as follows. We can also pass the Contract id in the similar manner.

Passing parameters like this we may always make sure to have correct values for every parameter in the next page and avoid getting below error.

Apart from this, I had also posted how to handle the previous URL through the parameter and importance of doing so. To read the same you can go through below link.

http://sagecrmaddons.blogspot.com/search/label/url

Moreover you can refer some more topics on this subject posted on our blog site through the search URL http://sagecrmaddons.blogspot.com/search?q=url. Here you will find the tips to handle navigation issues, execution of the containers etc. You can search through the contents on this blog to get many scripts for handling the page navigation and URL parameters through buttons, hiding showing of the fields, buttons etc.
Stay tuned for more updates on this subject. In the next post I will be explaining how to create URL’s on server side and then access them to client side, getting key values and creating the URL’s on client side.

If you find this content useful, please drop us an email at crm@greytrix.com.