Jarl Gjessing
Posts: 0
Joined: Sat May 02, 2015 2:26 pm

How can I use input field for DB query

In the mapper I'd like the where clause to include a text from a input field.
But how?
I have the field set up as in the screenshot.
And I would like for the $UnitNumber to be "replaced" with the inputfield.
I know, of course, that I cannot use $UnitNumber, but there MUST be some way to have the text from the input field to be inserted instead of it.
Thanks in advance Image

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

How can I use input field for DB query

Hi Jarl,

Here is a solution for your case:

  1. Open "before send" mapping for this service datasource.

  2. Create link from your input component to "where" request parameter.

  3. Click on "JS" button for just created link.

  4. Populate JS editor with following JS code:

    pre

    console.log("search for UnitNumber with value = '" + value + "'");

    //Check "UnitNumber" name.
    var whereObject = {"UnitNumber": value};

    return JSON.stringify(whereObject);

    /pre

    Regards.

Jarl Gjessing
Posts: 0
Joined: Sat May 02, 2015 2:26 pm

How can I use input field for DB query

Amazing! I was not aware that the JS item was an editable field. Thanks and sorry for disturbing

Jarl Gjessing
Posts: 0
Joined: Sat May 02, 2015 2:26 pm

How can I use input field for DB query

Except, now I get:
Refresh Exception: c15r: component facade not found
Error: c15r: component not found
throw new Error("c15r: component not found");
:-(

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

How can I use input field for DB query

Hi Jarl,

It seem you tried to access component that's not yet/already on the page.

Please check whether you don't have any other mapping to parent component.

Also you can delete other services to make sure what actual service causes this problem.

Regards.

Jarl Gjessing
Posts: 0
Joined: Sat May 02, 2015 2:26 pm

How can I use input field for DB query

Hi, thanks for a prompt reply.
I don't have any other mappings, and this is the only service.
I think now, that this is a network/firebug issue, since I randomly see this on other components. I moved on with other parts of the app, while waiting for an answer so I don't know if this is still an issue or if it were as random as with the others.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

How can I use input field for DB query

Hi Jarl,

Thanks for this update. Could you please provide us with your app public link and describe steps to reproduce this issue in your app?

Thanks.

Return to “Issues”