R
RayTheOtherRay
I use the following code segment as part of a form button on an Excel
PivotTable generated as Office Web Components on a web page.
//EV_TCNs FieldSet
var fstcns = fa.FieldSets('[EV_TCNs]');
if (fstcns.AllIncludeExclude == 2) //there is filtering
{
var eactcnlevel = 'none';
var eactcnvalue = 'none';
var fldtcn = fstcns.Fields('[EV_TCNs].[TCN]');
if (fldtcn.IncludedMembers != null)
{
x = new VBArray(fldtcn.IncludedMembers);
eactcnlevel = 'tcn'
eactcnvalue = x.getItem(0).UniqueName;
}
var fldcon = fstcns.Fields('[EV_TCNs].[CON]');
if (fldcon.IncludedMembers != null)
{
x = new VBArray(fldcon.IncludedMembers);
eactcnlevel = 'con';
eactcnvalue = x.getItem(0).UniqueName;
}
var fldordertype = fstcns.Fields('[EV_TCNs].[Order Type]');
if (fldordertype.IncludedMembers != null)
{
x = new VBArray(fldordertype.IncludedMembers);
eactcnlevel = 'ordertype';
eactcnvalue = x.getItem(0).UniqueName;
}
var fldreportas = fstcns.Fields('[EV_TCNs].[Report As]');
if (fldreportas.IncludedMembers != null)
{
x = new VBArray(fldreportas.IncludedMembers);
eactcnlevel = 'reportas';
eactcnvalue = x.getItem(0).UniqueName;
}
var fldcontract = fstcns.Fields('[EV_TCNs].[Contract]');
if (fldcontract.IncludedMembers != null)
{
x = new VBArray(fldcontract.IncludedMembers);
eactcnlevel = 'contract';
eactcnvalue = x.getItem(0).UniqueName;
}
var fldshortname = fstcns.Fields('[EV_TCNs].[Short Name]');
if (fldshortname.IncludedMembers != null)
{
x = new VBArray(fldshortname.IncludedMembers);
eactcnlevel = 'shortname';
eactcnvalue = x.getItem(0).UniqueName;
}
setCookie('eactcnlevel', eactcnlevel);
setCookie('eactcnvalue', eactcnvalue);
}
The purpose is to read through the currently filtered values in the
[EV_TCNs] Field Set of the Filter Axis and determine the state of the
user interaction to produce cookies to retain the user preferences when
they next open the page.
If there are no members in the specific .IncludedMembers property,
subscript references to it yeild, "Subscript out of range." I'm using
the condition of "!= null" to avoid this, but am now finding that at
the fldtcn level, it is getting past that condition, but still giving
the "Subscript out of range" message. I don't know how to inspect the
values of the .IncludedMembers array when subscript references cause
error. I'm looking for other ways to determine that there is nothing
there.
Thanks in advance!
Ray <><
PivotTable generated as Office Web Components on a web page.
//EV_TCNs FieldSet
var fstcns = fa.FieldSets('[EV_TCNs]');
if (fstcns.AllIncludeExclude == 2) //there is filtering
{
var eactcnlevel = 'none';
var eactcnvalue = 'none';
var fldtcn = fstcns.Fields('[EV_TCNs].[TCN]');
if (fldtcn.IncludedMembers != null)
{
x = new VBArray(fldtcn.IncludedMembers);
eactcnlevel = 'tcn'
eactcnvalue = x.getItem(0).UniqueName;
}
var fldcon = fstcns.Fields('[EV_TCNs].[CON]');
if (fldcon.IncludedMembers != null)
{
x = new VBArray(fldcon.IncludedMembers);
eactcnlevel = 'con';
eactcnvalue = x.getItem(0).UniqueName;
}
var fldordertype = fstcns.Fields('[EV_TCNs].[Order Type]');
if (fldordertype.IncludedMembers != null)
{
x = new VBArray(fldordertype.IncludedMembers);
eactcnlevel = 'ordertype';
eactcnvalue = x.getItem(0).UniqueName;
}
var fldreportas = fstcns.Fields('[EV_TCNs].[Report As]');
if (fldreportas.IncludedMembers != null)
{
x = new VBArray(fldreportas.IncludedMembers);
eactcnlevel = 'reportas';
eactcnvalue = x.getItem(0).UniqueName;
}
var fldcontract = fstcns.Fields('[EV_TCNs].[Contract]');
if (fldcontract.IncludedMembers != null)
{
x = new VBArray(fldcontract.IncludedMembers);
eactcnlevel = 'contract';
eactcnvalue = x.getItem(0).UniqueName;
}
var fldshortname = fstcns.Fields('[EV_TCNs].[Short Name]');
if (fldshortname.IncludedMembers != null)
{
x = new VBArray(fldshortname.IncludedMembers);
eactcnlevel = 'shortname';
eactcnvalue = x.getItem(0).UniqueName;
}
setCookie('eactcnlevel', eactcnlevel);
setCookie('eactcnvalue', eactcnvalue);
}
The purpose is to read through the currently filtered values in the
[EV_TCNs] Field Set of the Filter Axis and determine the state of the
user interaction to produce cookies to retain the user preferences when
they next open the page.
If there are no members in the specific .IncludedMembers property,
subscript references to it yeild, "Subscript out of range." I'm using
the condition of "!= null" to avoid this, but am now finding that at
the fldtcn level, it is getting past that condition, but still giving
the "Subscript out of range" message. I don't know how to inspect the
values of the .IncludedMembers array when subscript references cause
error. I'm looking for other ways to determine that there is nothing
there.
Thanks in advance!
Ray <><