You need to sign in to do that
Don't have an account?
API Endpoint Issue with merged fields
Can anyone help with this?
I thought this would be the simplest part of my day but it isn't. I have just created a class that pulls down nodes from an XML file from an external server and inserted that into SFDC.
That all works fine when I use a hardcoded end point.
But my issue is I need a dynamic endpoint because the URL I pass through the external server will always have different content based on latitude and longitude fields that I have stored in a custom object called Incident__C.
The idea is that the my xml parser class is called from a trigger that runs AFTER an insert so I should be able to pick up fields froma newly created Incident__c record to create and end point. Only I can't get it to work.
Any ideas - heres my endpoint from the class....
req.setEndpoint('http://www.uk-postcodes.com/latlng/latitude__c,longitude__c.xml');
It never pulls through the fields from the record that has just been triggered.
Thoughts? Do I need to reference the newly created Incident__c somehow for these fields to be picked up?
Do you have to treat merged fields differently in a class?
If I am not wrong following is your future method call:
All Answers
String strEndPoint = 'http://www.uk-postcodes.com/latlng/' + fieldname1 + '/' + fieldname2 + '.xml';
req.setEndpoint(strEndPoint );
You may not be able to refer them directly as latitude__c,longitude__c
Class must be containing instance of Incident__c object.
For ex. incident
so fieldname1 should be incident.latitude__c and fieldname2 will should be incident.longitutde__c
Thanks for coming back so quickly - oddly that didn't work though.
Heres the part of my class...
And here's the debug....
Am I missing something obvious? Should I be querying the record for the data first?
indeed you will require to make a query and bring values for those fields first.
Oh dear - not my strong point at all.
How would I get the right select statement put together?
What criteria would I use to pull data from a record that has just set off the trigger?
COmplete stab in the dark but is this anywhere near it?
Incident__c Lat = [SELECT Incident__c.latitude__c
FROM Incident__c
WHERE Incident__c(Id);
I just want the record that has started the trigger - how do I state that in the where clause?
Thanks for the swift responses.
I haven't tested this out, but give this a shot:
And then you reference each coordinate:
Hope this helps.
Thanks for coming back to me but that select stateemnt produces a null exception on the tigger new{0) section.
So frustrating - I feel I am so close and your post above makes sense to call the results from the statement.
The code justs seems to think that there is no data in the asved record after insert.
Any more thoughts on the select statement?
Just another thought here. The iD of my newly created record is - a00T0000002jWZZ - this ID is holding my coordinates.
However when I debug the ID i get the same reference plus three more characters - a00T0000002jWZZIA2
Just wondered if that was forcing my class to search for a record that didn't exist because it was adding three extra characters.
What type of trigger you have written? I will like to know on which object and its event. I you have written that on Incident then i dont think you will need to make any query.
This is the trigger..... what do you think?
If I am not wrong following is your future method call:
eprasu
I want to sincerely thank you for that.
That works spot on.
Thank you very much.
Glad to help you!