Page 1 of 1
Use API to find User to Policy relationship
Posted: Sun Apr 19, 2015 4:20 pm
by Yajasi
Running 8.0.5 CE on Ubuntu 14.04.
I'm trying to use the API to find which users have a Meal Policy. There doesn't seem to be a report which identifies this. Which API class do I use to do that?
I tried the following, but got an error.
Code: Select all
$ttAPI_group = new TimeTrexClientAPI( 'PolicyGroup' );
$group_factory = $ttAPI_group->getMainClassObject();
$meals = $group_factory->getMealPolicy();
var_dump($meals);
PHP Notice: SOAP Fault: (Code: SOAP-ENV:Server, String: Function 'getMealPolicy' doesn't exist) - Request: Response: in /var/www/html/run/classes/modules/api/client/TimeTrexClientAPI.class.php on line 197
Re: Use API to find User to Policy relationship
Posted: Mon Apr 20, 2015 7:48 am
by shaunw
You need to get the PolicyGroup data, then pull the user and meal policy data from that, something along these lines:
Code: Select all
$ttAPI_group = new TimeTrexClientAPI( 'PolicyGroup' );
$retval = $ttAPI_group->getPolicyGroup();
$retval will now contain the result of all your policy groups in an array, which will have 'user' and 'meal_policy' array elements.
Re: Use API to find User to Policy relationship
Posted: Tue Apr 21, 2015 10:46 pm
by Yajasi
$retval will now contain the result of all your policy groups in an array, which will have 'user' and 'meal_policy' array elements.
Here is an excerpt of the return value. It does not have a 'user' or 'meal_policy' array element.
Code: Select all
array {
...
[10]=>
array(6) {
["id"]=>
int(44)
["name"]=>
string(20) "Staff - Mechanic"
["description"]=>
bool(false)
["total_users"]=>
int(11)
["updated_by"]=>
string(22) "TimeTrex Administrator"
["updated_date"]=>
string(14) "02-Apr-15 4:06"
}
[11]=>
array(6) {
["id"]=>
int(3)
["name"]=>
string(17) "Staff - Pilot"
["description"]=>
bool(false)
["total_users"]=>
int(11)
["updated_by"]=>
string(22) "TimeTrex Administrator"
["updated_date"]=>
string(14) "02-Apr-15 4:06"
}
}
Is there anything else I can try?
Re: Use API to find User to Policy relationship
Posted: Wed Apr 22, 2015 8:08 am
by shaunw
It seems as though you may not be logging into the API as a full administrator that has permissions to view the data you are looking for.
Re: Use API to find User to Policy relationship
Posted: Wed Apr 22, 2015 5:14 pm
by Yajasi
Thank you! We adjusted our permissions for the API user and were able to retrieve the desired information.