You need to sign in to do that
Don't have an account?
Scott0987
Apex Map help
I have a map that is Map<string, id> I want to get the information from the map. I have a variable that will have the key information thatI want to get from the map. If I put map.get(variable) I get a return of Null. If I put map.get('12345') I get the correct result. 12345 is the information in the map. If I use system.debug it shows that my variable has 12345. Any idea why if I use a variable in the map.get(HERE) I do not get a result?
Good for you -- I really appreciate your persistence and willingness to resolve things yourself
I was going to suggest displaying the values in hex to see the errant characters
You're going to need to do something like this
All Answers
Hi,
Can you show the key, value combination and how you are creating it?
Filelines splits a csv file that has been imported.
Assuming that 'values' is an array where the second position (that is, index elm = 1) is a Product2.name, then the prodMap.get(..) statement will work provided there are no case sensitive issues between the input and what you fetch from SFDC
Problems like this are readily resolvable with system.debug() - you can verify that prodMap contains all the entries you expect and then compare against values[1]
This is the bizarre thing to me. When I use the system.debug I get 115630 as values[1] and 115630 is one of the keys in the map, but prodMap.get(values[1]) returns null. On the other hand if I put prodMap.get('115630') that returns the correct result.
Scott -- are you sure that values[1] doesn't have a leading or trailing space, NBSP, or other unprintable character?
Thats a thought. I could use deleteWhitespace on both sides of it to eliminate that as an issue. I will give that a try and let you know. thanks for the help.
I added the deleteWhitespace to the put and get parts of the map but it still did not work. Any other ideas?
I think I found it. I think there is a return at the end of the number. Any idea how I can get rid of that?
Good for you -- I really appreciate your persistence and willingness to resolve things yourself
I was going to suggest displaying the values in hex to see the errant characters
You're going to need to do something like this
Thank you for your help. It was driving me nuts. I could not figure out why it was not working.
yes - this fell into the category of:
and other joys of inter-system communication
glad it was sorted