Thread: [Arsperl-users] question regarding the query() method
Brought to you by:
jeffmurphy
|
From: <ix...@on...> - 2005-04-27 10:16:59
|
I'm trying to figure out how to properly use qualifiers via the OO query()
method on the SHR:People form. my code is below :
my @entries = $remedy_form->query(
-query => '("Login Name" = "some_user")'
);
this returns an array of field headers but no entries.
i've verified that the 'Login Name' field exists under that name in the form
'Login Name' => 240000005
I suspect that I'm not understanding how to properly phrase a remedy query
and apologize if that is the case here. invoking query() with no arguments
properly returns all entry IDs for the form and i can properly perform a
get() on the form handle to retrieve the entry - i just can't seem to properly
format a filter on the query itself.
does anyone see anything boneheaded i'm doing here? i've tried various quoting
styles for the query, such as "(\"Login Name\" = \"some_user\")", 'Login name'
and 'Login' instead of 'Login Name' and omitting the spaces between the field
name and the '=' in the query as well as removing the parentheses around the
query but none of those seem to work for me. directly using ars_GetListEntry
acts identically.
one thing i've noted ( not sure if this is something the C API deals with or
not ) is that you can specify any field name in the qualifier, whether it
exists or not, and no error is thrown.
the deconstructed qualifier as returned by ars_perl_qualifier() looks like
$VAR1 = {
'oper' => 'rel_op',
'rel_op' => {
'left' => {
'value' => 'Login Name'
},
'right' => {
'value' => 'some_user'
},
'oper' => '=='
}
};
using the standard $all qualifier of "1=1" returns
$VAR1 = {
'oper' => 'rel_op',
'rel_op' => {
'left' => {
'value' => 1
},
'right' => {
'value' => 1
},
'oper' => '=='
}
};
( using "1=1" returns all entries properly, as does "1<2" and other queries
of that nature, so i think i've at least got the basic syntax down. what i'm
probably not understanding are what types of arguments i'm supposed to feed
to the qualifier constructor, tho the examples i've seen in the mailing list
seem to match up with what i'm trying to do )
a little stumped :) - thanks much for any help!
- tom
|
|
From: Carey M. B. <bla...@gm...> - 2005-04-27 13:17:17
|
Tom,
ARS "Advanced Search Bar" syntax goes something like this:
Field names (Current View's Label, or fields DB name) should be in
single quotes. (Or you can use the field ID too.)
Literal strings should be in double quotes.
integers are NOT quoted (double or single)
Spacing really does not matter that much. (Extra white space is
welcome, but sometimes "2AND" may not parse as well as "2 AND". So try
to use some white space or at least parentheses.)
API search strings only differ by this one simple (and easy to trip
over) difference:
The fields DATABASE NAME (Each field has multiple English names,
one for the DB name that is guaranteed to be unique on the form, and
one per view where the field is included for the users reference.)
should be in single quotes.
So if the field id is 240000005 and the fields DB name is 'Login Name'
the following two syntax should do the same thing:
'Login Name' =3D "some user"
vs.
'240000005' =3D "some user"
However, if the fields label (view dependent name) is actually 'Login
Name' and the field's DB name is 'Login' then the first example above
would fail and the second one should work. (and 'Login' =3D "some user"
should also work.)
BTW: Some people like to use the qq function to make keeping track of
the quotes a bit easier.
$query_String =3D qq/('Login Name' =3D "some_user")/
Then try to use:
-query =3D> $query_String
Date time fields are "integer" in nature. (you have likely already
found this.) So 'Create Date' > 0 really means 'Create Date' >
"1/1/1970 12:00:00 AM" (In the client Timezone.) [ Well that is how
the User tool work. The API might be less TZ sensitive.]
Selection fields are "integer in nature. (you have likely already found thi=
s.)=20
'Status' =3D 1 can also be written as 'Status' =3D "Assigned"
Oh, one final thing... I never use the OO interface. It is just one
more thing to "fight with" IMHO. Perl is just to easy to over
complicate with multiple layers in Perl. ARSPerl is fairly straight
forward as a whole. So if the OO interface just does not get the job
done... try the "real ARSPerl" functions. I bet you will have no
problems with them.
I also do not have a copy of your "SHR:People" form so please confirm
field details with your Remedy Administrator via the Admin tool.
HTH.
--=20
Carey Matthew Black
Remedy Skilled Professional (RSP)
ARS =3D Action Request System(Remedy)
Solution =3D People + Process + Tools
Fast, Accurate, Cheap.... Pick two.
Never ascribe to malice, that which can be explained by incompetence.
http://www.fellowshipchurch.com
On 4/27/05, the sign will be that life is awesome <ix...@on...> wrote:
> I'm trying to figure out how to properly use qualifiers via the OO query(=
)
> method on the SHR:People form. my code is below :
>=20
> my @entries =3D $remedy_form->query(
> -query =3D> '("Login Name" =3D "some_user")'
> );
>=20
> this returns an array of field headers but no entries.
>=20
> i've verified that the 'Login Name' field exists under that name in the f=
orm
>=20
> 'Login Name' =3D> 240000005
>=20
> I suspect that I'm not understanding how to properly phrase a remedy quer=
y
> and apologize if that is the case here. invoking query() with no argumen=
ts
> properly returns all entry IDs for the form and i can properly perform a
> get() on the form handle to retrieve the entry - i just can't seem to pro=
perly
> format a filter on the query itself.
>=20
> does anyone see anything boneheaded i'm doing here? i've tried various q=
uoting
> styles for the query, such as "(\"Login Name\" =3D \"some_user\")", 'Logi=
n name'
> and 'Login' instead of 'Login Name' and omitting the spaces between the f=
ield
> name and the '=3D' in the query as well as removing the parentheses aroun=
d the
> query but none of those seem to work for me. directly using ars_GetListE=
ntry
> acts identically.
>=20
> one thing i've noted ( not sure if this is something the C API deals with=
or
> not ) is that you can specify any field name in the qualifier, whether it
> exists or not, and no error is thrown.
>=20
> the deconstructed qualifier as returned by ars_perl_qualifier() looks lik=
e
>=20
> $VAR1 =3D {
> 'oper' =3D> 'rel_op',
> 'rel_op' =3D> {
> 'left' =3D> {
> 'value' =3D> 'Login Name'
> },
> 'right' =3D> {
> 'value' =3D> 'some_user'
> },
> 'oper' =3D> '=3D=3D'
> }
> };
>=20
> using the standard $all qualifier of "1=3D1" returns
>=20
> $VAR1 =3D {
> 'oper' =3D> 'rel_op',
> 'rel_op' =3D> {
> 'left' =3D> {
> 'value' =3D> 1
> },
> 'right' =3D> {
> 'value' =3D> 1
> },
> 'oper' =3D> '=3D=3D'
> }
> };
>=20
> ( using "1=3D1" returns all entries properly, as does "1<2" and other que=
ries
> of that nature, so i think i've at least got the basic syntax down. what=
i'm
> probably not understanding are what types of arguments i'm supposed to fe=
ed
> to the qualifier constructor, tho the examples i've seen in the mailing l=
ist
> seem to match up with what i'm trying to do )
>=20
> a little stumped :) - thanks much for any help!
>=20
> - tom
|
|
From: <ix...@on...> - 2005-04-27 18:58:59
|
> ARS "Advanced Search Bar" syntax goes something like this: > Field names (Current View's Label, or fields DB name) should be in > single quotes. (Or you can use the field ID too.) > Literal strings should be in double quotes. > integers are NOT quoted (double or single) > Spacing really does not matter that much. (Extra white space is > welcome, but sometimes "2AND" may not parse as well as "2 AND". So try > to use some white space or at least parentheses.) > > > API search strings only differ by this one simple (and easy to trip > over) difference: > The fields DATABASE NAME (Each field has multiple English names, > one for the DB name that is guaranteed to be unique on the form, and > one per view where the field is included for the users reference.) > should be in single quotes. > > > So if the field id is 240000005 and the fields DB name is 'Login Name' > the following two syntax should do the same thing: > > 'Login Name' = "some user" > > vs. > > '240000005' = "some user" > > > However, if the fields label (view dependent name) is actually 'Login > Name' and the field's DB name is 'Login' then the first example above > would fail and the second one should work. (and 'Login' = "some user" > should also work.) thanks to everyone for all the fast feedback! .. after posting last night i did discover that retrieving a mapping of the field entries to field ids via ars_GetFieldTable() and using the field id itself works fine for all cases i could think to throw at it. - '240000005' = "some_user" '240000005' like "%some%" etc when trying to enclose 'Login Name' in single quotes, i receive : EXCEPTION : type => 2 message => [ERROR] Unknown field referenced in query line (position 14 (( 'Login name'^ = "some_user" ))) (ARERR #1587) examining the form with remedy administrator, the ID is listed as '240000005' and the 'Name' is shown as 'Login Name' in the Database tab under Field Properties, so maybe i'm not looking in the proper place for the database name? for the time being things are fine so long as i've an easy way to form queries by caching the field ids via ars_GetFieldTable() - much better than dumping the entire database and post-filtering, heheh now all i've left to figure out is ars_GetListSchema() and i think i'll have everything i need to do what i want to do :) thanks again everyone! - tom |
|
From: Kelly L. <kel...@ra...> - 2005-04-27 14:03:16
|
Good day Tom,
I'm not as hep on the OO code, but in general you need to translate a =
text
qualifier into the functional code that Remedy uses.
Here's a code snippet of mine:
-------------------------------
my $qualString =3D '\'Status\' =3D 0 OR \'Completed Date\' =3D $NULL$ OR
\'Completed Date\' > $TIMESTAMP$ - (32*24*60*60)';
my $qual =3D ars_LoadQualifier($ctl, $cmsPlanServicesForm, $qualString) =
||
terminalExit("ERROR: failed in ars_LoadQualifier()\n$ars_errstr");
if (defined($qual)) {
%entries =3D ars_GetListEntry($ctl, $cmsPlanServicesForm, $qual, 0,
0);
} else {
terminalExit("failed in ars_LoadQualifier for
$qualString\n$ars_errstr");
}
-------------------------------
I just use the $qualString for convenience sake.
After you 'load' the qualifier, you use that encoded string in your =
query.
Note also the $ars_errstr - This is always worth checking if you think
something went wrong.
Hope that helps. Feel free to contact me for details on this.
Kelly Logan
Cybernetic Solutions, Inc.
(313) 586-8334
kel...@cy...
-----Original Message-----
From: ars...@ar...
[mailto:ars...@ar...] On Behalf Of the sign will be =
that
life is awesome
Sent: 04/27/2005 6:16 AM
To: ars...@ar...
Subject: [Arsperl-users] question regarding the query() method
I'm trying to figure out how to properly use qualifiers via the OO =
query()
method on the SHR:People form. my code is below :
my @entries =3D $remedy_form->query(
-query =3D> '("Login Name" =3D "some_user")'
);
this returns an array of field headers but no entries.
i've verified that the 'Login Name' field exists under that name in the =
form
'Login Name' =3D> 240000005
I suspect that I'm not understanding how to properly phrase a remedy =
query
and apologize if that is the case here. invoking query() with no =
arguments
properly returns all entry IDs for the form and i can properly perform a
get() on the form handle to retrieve the entry - i just can't seem to
properly format a filter on the query itself.
does anyone see anything boneheaded i'm doing here? i've tried various
quoting styles for the query, such as "(\"Login Name\" =3D =
\"some_user\")",
'Login name' and 'Login' instead of 'Login Name' and omitting the spaces
between the field name and the '=3D' in the query as well as removing =
the
parentheses around the query but none of those seem to work for me.
directly using ars_GetListEntry acts identically.
one thing i've noted ( not sure if this is something the C API deals =
with or
not ) is that you can specify any field name in the qualifier, whether =
it
exists or not, and no error is thrown.
the deconstructed qualifier as returned by ars_perl_qualifier() looks =
like
$VAR1 =3D {
'oper' =3D> 'rel_op',
'rel_op' =3D> {
'left' =3D> {
'value' =3D> 'Login Name'
},
'right' =3D> {
'value' =3D> 'some_user'
},
'oper' =3D> '=3D=3D'
}
};
using the standard $all qualifier of "1=3D1" returns
$VAR1 =3D {
'oper' =3D> 'rel_op',
'rel_op' =3D> {
'left' =3D> {
'value' =3D> 1
},
'right' =3D> {
'value' =3D> 1
},
'oper' =3D> '=3D=3D'
}
};
( using "1=3D1" returns all entries properly, as does "1<2" and other =
queries
of that nature, so i think i've at least got the basic syntax down. =
what
i'm probably not understanding are what types of arguments i'm supposed =
to
feed to the qualifier constructor, tho the examples i've seen in the =
mailing
list seem to match up with what i'm trying to do )
a little stumped :) - thanks much for any help!
- tom
-------------------------------------------------------
SF.Net email is sponsored by: Tell us your software development plans! =
Take
this survey and enter to win a one-year sub to SourceForge.net Plus =
IDC's
2005 look-ahead and a copy of this survey Click here to start!
http://www.idcswdc.com/cgi-bin/survey?id=3D105hix
_______________________________________________
Arsperl-users mailing list
Ars...@ar...
https://lists.sourceforge.net/lists/listinfo/arsperl-users
|
|
From: Richard H. <rl...@ls...> - 2005-04-27 15:03:59
|
Folks,
There's a nice way to prevent the "sea" of backslashing and excess
quotes, namely to use Perl's "q" and "qq" operators. For example, Kelly's
definition of $qualString could be written:
my $qualString = q{
'Status' = 0 OR 'Completed Date' = $NULL$ OR 'Completed Date' ....
};
Doing this allows you to cut n paste queries you've tried out in the Remedy
GUI straight into your Perl code.
Cheers,
Richard.
-----Original Message-----
From: ars...@ar...
[mailto:ars...@ar...] On Behalf Of Kelly Logan
Here's a code snippet of mine:
-------------------------------
my $qualString = '\'Status\' = 0 OR \'Completed Date\' = $NULL$ OR
\'Completed Date\' > $TIMESTAMP$ - (32*24*60*60)';
|