Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Customer & Partners, DEC. 9, 11 AM ET: Qlik Product & Strategy Roadmap Session: Data Analytics REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro works well on Desktop but not in IE

Macro code below works well on Desktop but doesn't work in IE. Its a simple macro that sets 'Always one selected' Property of a field and clears uopn a switch from one view to the other. Any help will be appreciated.  '%_Alignment' = 1 or 2 based on the view. 'vSalesFroce' = 1 declared in variables in a QVW.

sub ClearAlignment
      set vAlignSelected = ActiveDocument.fields("%_Alignment").GetSelectedValues
       select case vAlignSelected.Item(0).Number
            case 1
                  call ClearSalesForce
            case 2
                  call ClearPoliticalGeo
       end select
end sub

sub ClearSalesForce
      set v = ActiveDocument.Variables("vSalesForce")
      if  v.getcontent.string = 1 then
            ClearAlwaysOne("Sales Force")
            ActiveDocument.Fields("Sales Force").Clear
            set SelectValue = ActiveDocument.fields("CF_ID").GetPossibleValues
            call SetAlwaysOne("CF_ID", SelectValue.Item(0).Text)
      end if 
end sub

sub ClearPoliticalGeo
           set v1 = ActiveDocument.Variables("vSalesForce")
           if  v1.getcontent.string = 1 then
                 ClearAlwaysOne("CF_ID")
                 ActiveDocument.Fields("CF_ID").Clear
                 set SelectValue = ActiveDocument.fields("Sales Force").GetPossibleValues
                 call SetAlwaysOne("Sales Force", SelectValue.Item(0).Text)
           end if
end sub

sub SetAlwaysOne(OnlyOne,ToSelect)
      ActiveDocument.Fields(OnlyOne).Select ToSelect
      set fld = ActiveDocument.GetField(OnlyOne)
      set prop = fld.GetProperties
      prop.OneAndOnlyOne = true
      fld.SetProperties prop
end sub

sub ClearAlwaysOne(OnlyOne)
      set fld = ActiveDocument.GetField(OnlyOne)
      set prop = fld.GetProperties
      prop.OneAndOnlyOne = false 
      fld.SetProperties prop
      ActiveDocument.Fields(OnlyOne).Clear 
end sub

7 Replies
Not applicable
Author

By the way I am using IE 8 and QV 9.0 SR6.

Not applicable
Author

I had this problem once and it was that the IE Plug under "My Preferred Client" was looking looking at Ajax or Java. This may not be your problem thought.

Stephen

Not applicable
Author

We got this whole functionality working using actions and triggers. We eliminated all five macros with actions and triggers.

suniljain
Master
Master

pls check your IE Plugin version.

it should be same with your desktop and server version.

tduarte
Partner
Partner

nims1983 wrote:

We got this whole functionality working using actions and triggers. We eliminated all five macros with actions and triggers.

I'm curious nims1983. How did you manage to set a field to "Always One Select" without the use of a macro?

Not applicable
Author

We are triggering an OnSelect Event on fields that require always one selected property. For example in this case, they are SalesForce and CF_ID.

We've force the selection on open document event on CF_ID and then

use below in 'Select Field'

=if(getselectedcount(SalesForce) =0,if(num(%_Alignment)=2, 'SalesForce','CF_ID')) and as search string

=if(num(%_Alignment)=2, '$(vSFPick)','$(vGeoPick)')

where vSFPick = minstring(SalesForce) and vGeoPick = minstring(CF_ID)

I hope it makes sense.

Not applicable
Author

Always one selecte property can be set by creating a varible. for example, in this case

vSFSelect = getSelectedCount(SalesForce)

and then fire an variable event trigger on

vSFSelect

Event type : OnChange

Action: Select in Field

Field : if($(vSFSelet) <> 1, 'SalesForce')

Search String : ='$(vSFPick)'

where vSFPick is another variable and is defined as stated above.