Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1061167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:26:17+00:00 2026-05-16T18:26:17+00:00

Update: Thanks Ben, I decided to copy the URL to another structure and modify

  • 0

Update:

Thanks Ben, I decided to copy the URL to another structure and modify that one with StructUpdate(). Here’s the code if anyone’s interested (specific to my application, but you can edit the lines with comments to get a useful function).

function rebuildURL(key, value)
{
 var URLstring = "";
 var VarCount = 0;
 var tmpURL = duplicate(URL);
 var VarSeparator = "";
 structUpdate(tmpURL, arguments.key, arguments.value);
 for (key in tmpURL)
 {
  if (tmpURL[key] neq "" and tmpURL[key] neq "10000" and tmpURL[key] neq "1") `<!--- remove the tmpURL[key] neq "10000" and "1"--->`
  {
   if (VarCount neq 0)
   {
    VarSeparator = "&";
   }
   else
   {
    VarSeparator = "";
   }
   URLstring = URLstring & VarSeparator & "#Lcase(key)#" & "=#Lcase(tmpURL[key])#";
   VarCount = VarCount + 1;
  }

 }
 structClear(tmpURL); `<!---not sure if this is necessary, but probably can't hurt unless you are processing thousands of links --->`
 return(URLstring);
}

Thanks again!
Scott


Hey guys,

I’m writing a custom function to rework the URL for links in my pages, and I’m getting the following error:

Complex object types cannot be converted to simple values.

The expression has requested a variable or an intermediate expression result as a simple value, however, the result cannot be converted to a simple value. Simple values are strings, numbers, boolean values, and date/time values. Queries, arrays, and COM objects are examples of complex values.
The most likely cause of the error is that you are trying to use a complex value as a simple one. For example, you might be trying to use a query variable in a cfif tag.

The error occurred in C:\ColdFusion8\wwwroot\pascalnew\turbos.cfm: line 8
Called from C:\ColdFusion8\wwwroot\pascalnew\turbos.cfm: line 108
Called from C:\ColdFusion8\wwwroot\pascalnew\turbos.cfm: line 93
Called from C:\ColdFusion8\wwwroot\pascalnew\turbos.cfm: line 1
Called from C:\ColdFusion8\wwwroot\pascalnew\turbos.cfm: line 1

6 :  URLvar = "#URL#";
7 :  switch(param)
8 :  {
9 :   case 'mfr':
10 :   {

Here’s my function code:

<cfscript>
function SetURL(param, paramval)
{
 URLvar = "#URL#";
 switch(param)
 {
  case 'mfr':
  {
   IF (URLvar contains "mfr") 
   {
    REReplaceNoCase(URLvar, "mfr=^[^\&]", "mfr=#paramval#", "All");
   }
   break;
  }
 }
 return(URLvar);
}
</cfscript>

Here’s what I was testing it with:

<cfset urlvar = SetUrl("mfr", "edwards")>
<cfdump var="#urlvar#">

How is “mfr” a complex variable??

Thanks,
Scott

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T18:26:17+00:00Added an answer on May 16, 2026 at 6:26 pm

    When you use CFScript, some versions report the beginning of the block as the line with the error.

    When you assign “#URL#” to URLVar, you are creating a pointer to the URL scope. then, you attempt to use the contains operator on it. Contains, however, only compares two simple values.

    So, your attempt to reference a complex value as a scalar actually comes here:

    IF (URLvar contains "mfr") 
    {
        REReplaceNoCase(URLvar, "mfr=^[^\&]", "mfr=#paramval#", "All");
    }
    

    At a guess, you are trying to look at the URL itself, not the URL scope. You can assemble this from parts of the CGI scope, including SERVER_NAME, SCRIPT_NAME, AND QUERY_STRING (or you can look at the individual part you need).

    Added: If you want to know if a variable is passed in the url, I think you are overthinking this. Let’s say you have a param and a paramval to replace it with. You could do it like this:

    function paramReplace(param, paramVal, scope)
    {
        if(structkeyexists(arguments.scope, arguments.param))
        {
            arguments.scope[arguments.param] = arguments.paramVal;
        }
    }
    paramReplace("mfr", "fred", URL);
    

    This simply uses structKeyExists to find out if that variable exists in the appropriate scope, then replaces the value if it does. If you need to rebuild your actual query string, you can do so later. This avoids scenarios where you get bad data if your query string contains something like “zone=mfr”.

    I’ve not tested this — it’s off the cuff — so it may need tweaking, but it should get you started.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to update my SQL lite database with the native update-method of
I am using a 3rd-party rotator object, which is providing a smooth, random rotation
I would like to remove/delete a migration file. How would I go about doing
I have found this example on StackOverflow: var people = new List<Person> { new
I have a login.jsp page which contains a login form. Once logged in the
I'm trying to write test harness for part of my Android mapping application. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.