Quantcast
Viewing all articles
Browse latest Browse all 2504

Connect API: fetch() treating integer variables as strings (5 Comments)

Topic by Grace Beven

Content

I keep having the repeated problem of an object's fetch method not treating integer variables as integers.

For example:

RNCPHP\ServiceCategory::fetch(1)  --->Works perfectly fine

RNCPHP\ServiceCategory::fetch($incident->Category->ID)  --->Tries to search as though i passed in a string

RNCPHP\ServiceCategory::fetch(intval($incident->Category->ID)) --->For some reason the call to intval in this situation fails and it tries to fetch ID 0

var_dump($incident->Category->ID)   --->prints out int(82)

var_dump(intval($incident->Category->ID))   --->prints out int(82)

 

My workaround to the above issue ended up being this...

$catArray = RNCPHP\ServiceCategory::find("ID = ".((string)$incident->Category->ID));   --->Works fine

 

I am at a complete loss on this one and would really like some help. I will admit that I am not familiar with all of the intricacies of PHP (and I know there is a lot) so I suspect that maybe I am missing something related to how PHP works rather than how Connect works but I don't really know what is happening here. 

Version

Service Cloud Feb2015

Viewing all articles
Browse latest Browse all 2504

Trending Articles