Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Clear specific field with javascript

Hi,

I want to clear a specific field when a button is clicked in my extension. The button is a simple input type = button with an id = 'canceldata' where I can catch actions by using:

$("#canceldata").click(function() {

     var doc = Qv.Document;

     console.log(doc);

});

This works, but I want a function that takes a field name (For example clearField("Year")) as parameter and clears that field of any values selected. Is there such a function? I have scouted the JS API but with no luck.

JsDoc Reference - Qv.Document

Thanks.

Mikael

1 Solution

Accepted Solutions
Not applicable
Author

Solved this by having a "on update" variable trigger that clears the field if the variable is updated. I update the variable in my javascript by:

var doc = Qv.GetCurrentDocument();

doc.SetVariable("checkRRG", 1);

Not the best way but it works for now.

View solution in original post

4 Replies
marcus_sommer

Have you tried to use the inbuilt action-functionalities of clearing a field? Further if you be able to select any values you could clear the field with the search-string = null().

- Marcus

Not applicable
Author

Hi Markus,

That is what I am after, a way of calling for example the QV actions of for example a button from javascript. I have an extension object that is shown with hide/show condition when the user selects a value from the field "ReportRowGroup". When the user clicks on the input button within my extension object I want to call the clear function for that field.

When I try to call functions like Qv.Document.Object.Data.ClearAllButThis()  the console says that it's not a function.

I know I can always solve the problem by adding a QV object with an action that clears the selection but its not as good looking as I want

Not applicable
Author

Solved this by having a "on update" variable trigger that clears the field if the variable is updated. I update the variable in my javascript by:

var doc = Qv.GetCurrentDocument();

doc.SetVariable("checkRRG", 1);

Not the best way but it works for now.

marcus_sommer

I haven't enough experience with this to help you further. Maybe you could look for another extensions which are using similar stuff to adapt it to your solution. Good luck.

- Marcus