How to check if GetCgiVariable("id") exist


I want to check if the QueryString Variable in URL exist.

How can I do that ?

I'm in the CustomerCenter, I Have a queryString Parameter in one case and in other case this parameter doesn't exist.

I want to check it.

Actually i have got an error because the parameter doesn't exist.

Thanks for your reponse

RE: How to check if GetCgiVariable("id") exist

There are more than one way to do this, but the easiest is to check if the returned string is null. If it is null, then it does not exist:

String var = getCgiVariable("nothing");
if (var.isNull())
printLine("Does not exist");
printLine("Value of variable is: " + var);

The other approach is to use "Map all = getCgiVariables()", which will get all cgi variables. Then you can use "all.exists("<myvar>")" which will return true if the map contains that cgi variable,

Af: Stian Andre Olsen 11. nov 2020

RE: How to check if GetCgiVariable("id") exist

To check CGI variables I often do this:

Map cgi = getCgiVariables();
  // Do Code


Just saw that Stian mentioned the same approach :)

Af: Simen Mostuen Iversen 11. nov 2020