Created
July 23, 2012 19:02
-
-
Save awrowse/3165453 to your computer and use it in GitHub Desktop.
Connect PHP Utility
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CPHPUtil { | |
/** | |
* Find a LookupName's ID in Connect PHP | |
* @param string $label Label to find as lookup name | |
* @param string $field_name Field name to compare label against lookup names. | |
* @param string $object Object that contains the field to search | |
* @return int|boolean Returns ID if found, false otherwise | |
*/ | |
static protected function FindIdForLabelWithNamedID($label, $field_name, $object = 'RightNow\Connect\v1_1\IncidentCustomFields'){ | |
/* Grab Named Values array ========================================== */ | |
$named_ids = RightNow\Connect\v1_1\ConnectAPI::getNamedValues($object, $field_name); | |
/* Look through Named Values to find matching lookup name =========== */ | |
foreach($named_ids as $named_id_pair) { | |
$lookup_name = $named_id_pair->LookupName; | |
if($lookup_name == $label){ | |
/* Found Match. Return ID =================================== */ | |
$id = $named_id_pair->ID; | |
return $id; | |
} | |
/* Match Not Found. Loop again ================================== */ | |
} | |
/* Did not find LookupName in object. Return false ================== */ | |
return false; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment