Page 1 of 1

How do you add and remove tags from a user?

Posted: Thu May 07, 2015 11:54 pm
by Yajasi
I've tried using the API class CompanyGenericTag function called deleteCompanyGenericTag(), but this only removes the tag from the database. Opening the employee in TimeTrex shows the tag is still there but orphaned.

Code: Select all

// this code leaves an orphaned tag still associated with the user record
$ttAPI = new TimeTrexClientAPI( 'CompanyGenericTag' );
$ttAPI->deleteCompanyGenericTag($tag['id'])
I've tried modifying the ['tag'] element of the array of data obtained from the getUserfunction in the API class User, but the tag still remains orphaned.

Code: Select all

// this code does not remove a tag on the user record
$ttAPI = new TimeTrexClientAPI( 'User' );
$ttData = $ttAPI->getUser(null, true)->getResult();
$tagged_entry = $ttData[0];
$tagged_entry['tag'] = str_replace($tag_string,'',$tagged_entry['tag']);
$ttAPI->setUser($tagged_entry);

Re: How do you add and remove tags from a user?

Posted: Fri May 08, 2015 10:57 am
by shaunw
Send the 'tag' array element like this:

Code: Select all

'tag' => 'keepthistag, -removethistag'
So basically just add a "-" infront of the tag you want to remove, while keeping any other tags there.

Re: How do you add and remove tags from a user?

Posted: Fri May 15, 2015 12:39 am
by Yajasi
Thanks! That worked.