Calling javascript from formula

I am facing problem while calling javascript function from formula.

I have one button which has formula @command([filesave]); @urlopen(“javascript:abc()”);

It is not working. Other way I have adopted :

Button A :@command([filesave]); ID name=A

Button B :document.getElementById(“A”).click();

           abc();

This method also creating problem. When I click on Button B it will first call javascript function after then it will execute the formula.

But I want that first formula executes then it will call javascript function.

Please help.

Subject: Calling javascript from formula

YOu’ve posted this before.

Why are you calling @command([FileSave])? You can’t save the document from the web browser without submitting it to the server. You would normally do this with:

@command[FileSave]);

@command([FileCloseWindow]);

If you don’t need to save the document, suggest simply using the Web client javascript onClick event on the action/hotspot button and just calling abc();

What does abc() do anyway??

Subject: RE: Calling javascript from formula

The one I have given is an example but the purpose is that I want to search a document from view. So I have formulas which will make a query.

FieldSearchSubQuery1 := @If( @Trim(fieldword1) = “” | @Trim(fieldword1) = “<–Any–>” ; “” ; @ReplaceSubstring(@Implode(" Field " + CheckField1 + " CONTAINS " + fieldword1 ; “+") ; "+” ; " Or " ));

FieldSearchSubQuery2 := @If( @Trim(fieldword2) = “” | @Trim(fieldword2) = “<–Any–>”; “” ; @ReplaceSubstring(@Implode(" Field " + CheckField2 + " CONTAINS " + fieldword2 ; “+") ; "+” ; " Or " ));

FieldSearchSubQuery3 := @If( @Trim(fieldword3) = “” | @Trim(fieldword3) = “<–Any–>”; “” ; @ReplaceSubstring(@Implode(" Field " + CheckField3 + " CONTAINS " + fieldword3 ; “+") ; "+” ; " Or " ));

FieldSearchSubQuery4 := @If( @Trim(fieldword4) = “” | @Trim(fieldword4) = “<–Any–>”; “” ; @ReplaceSubstring(@Implode(" Field " + CheckField4 + " CONTAINS " + fieldword4 ; “+") ; "+” ; " Or " ));

FieldSearchSubQuery5 := @If( @Trim(fieldword5) = “” | @Trim(fieldword5) = “<–Any–>”; “” ; @ReplaceSubstring(@Implode(" Field " + CheckField5 + " CONTAINS " + fieldword5 ; “+") ; "+” ; " Or " ));

FieldSearchSubQuery6 := @If( @Trim(fieldword6) = “” | @Trim(fieldword6) = “<–Any–>”; “” ; @ReplaceSubstring(@Implode(" Field " + CheckField6 + " CONTAINS " + fieldword6 ; “+") ; "+” ; " Or " ));

FieldSearchSubQuery7 := @If( @Trim(fieldword7) = “” | @Trim(fieldword7) = “<–Any–>”; “” ; @ReplaceSubstring(@Implode(" Field " + CheckField7 + " CONTAINS " + fieldword7 ; “+") ; "+” ; " Or " ));

AdjustedLowerDt := @If(@Trim(fieldword8) = “” | @Trim(fieldword8) = “<–Any–>”; “” ; @Adjust(@Today ; - @TextToNumber(@Right( fieldword8 ; " - ")) ; 0 ; 0 ; 0 ; 0 ;0) );

AdjustedUpperDt := @If(@Trim(fieldword8) = “” | @Trim(fieldword8) = “<–Any–>”; “” ; @Adjust(@Today ; - @TextToNumber(@Left( fieldword8 ; " - ")) ; 0 ; 0 ; 0 ; 0 ;0) ) ;

FieldSearchSubQuery8 := @If( @Trim(fieldword8) = “” | @Trim(fieldword8) = “<–Any–>”; “” ; "( Field JoiningDt > " + @Text(AdjustedLowerDt) + " AND Field JoiningDt < " + @Text(AdjustedUpperDt) + “)”);

FieldSearchQuery1 := @If( @Trim(FieldSearchSubQuery1) = “” ; “” ;@Trim(FieldSearchSubQuery1) );

FieldSearchQuery2 := @If( @Trim(FieldSearchSubQuery2) = “” ; “” ; FieldSearchQuery1 = “” ; @Trim(FieldSearchSubQuery2) ;" " + AndOr2 + " " + @Trim(FieldSearchSubQuery2) );

FieldSearchQuery3 := @If( @Trim(FieldSearchSubQuery3) = “” ; “” ; FieldSearchQuery1 + FieldSearchQuery2 = “” ; @Trim(FieldSearchSubQuery3) ; " " + AndOr3 + " " + @Trim(FieldSearchSubQuery3) );

FieldSearchQuery4 := @If( @Trim(FieldSearchSubQuery4) = “” ; “” ; FieldSearchQuery1 + FieldSearchQuery2 + FieldSearchQuery3 = “” ;

@Trim(FieldSearchSubQuery4) ; " " + AndOr4 + " " + @Trim(FieldSearchSubQuery4) );

FieldSearchQuery5 := @If( @Trim(FieldSearchSubQuery5) = “” ; “” ; FieldSearchQuery1 + FieldSearchQuery2 + FieldSearchQuery3 + FieldSearchQuery4 = “” ; @Trim(FieldSearchSubQuery5) ; " " + AndOr5 + " " + @Trim(FieldSearchSubQuery5) );

FieldSearchQuery6 := @If( @Trim(FieldSearchSubQuery6) = “” ; “” ; FieldSearchQuery1 + FieldSearchQuery2 + FieldSearchQuery3 + FieldSearchQuery4 + FieldSearchQuery5 = “” ; @Trim(FieldSearchSubQuery6) ; " " + AndOr6 + " " + @Trim(FieldSearchSubQuery6) );

FieldSearchQuery7 := @If( @Trim(FieldSearchSubQuery7) = “” ; “” ; FieldSearchQuery1 + FieldSearchQuery2 + FieldSearchQuery3 + FieldSearchQuery4 + FieldSearchQuery5 + FieldSearchQuery6 = “” ; @Trim(FieldSearchSubQuery7) ; " " + AndOr7 + " " + @Trim(FieldSearchSubQuery7) );

FieldSearchQuery8 := @If( @Trim(FieldSearchSubQuery8) = “” ; “” ; FieldSearchQuery1 + FieldSearchQuery2 + FieldSearchQuery3 + FieldSearchQuery4 + FieldSearchQuery5 + FieldSearchQuery6 + FieldSearchQuery7 = “” ; @Trim(FieldSearchSubQuery8) ; " " + AndOr8 + " " + @Trim(FieldSearchSubQuery8) );

FieldSearchQuery := @Trim(FieldSearchQuery1 + FieldSearchQuery2 + FieldSearchQuery3 + FieldSearchQuery4 + FieldSearchQuery5 + FieldSearchQuery6 + FieldSearchQuery7 + FieldSearchQuery8 );

@If(QueryWOFieldSearch = “” ; @Trim(@SetField(“Query1”;FieldSearchQuery)) ; @Trim(FieldSearchQuery) = “” ; @SetField(“Query1”;QueryWOFieldSearch) ; @SetField(“Query1”;QueryWOFieldSearch + " And (" + @Trim(FieldSearchQuery) + “)”) )

After then in the same button I need the callSearch() which will search for the query generated by the above formula. If I give formula on one button and callSearch() function on seperate button then it does not sounds good that user have to click on two buttons for search. So this is why I need all this on one button.

Subject: RE: Calling javascript from formula

OK. I see what you are trying to do.

There is a much easier way of doing this:

See my earlier post:

https://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/3ea1cb0492ce89a6852571d300487fdc?OpenDocument