Here's an example you can play with, too.
This is method to modify existing Entry object with updates to field/value
pairs and addition of new key/value pairs.
The return is an Entry object that is ready to use in the update entry call to
Remedy. The Entry is updated by removing existing key/values from the
Entry object that has "old" data and then adding in "updated" data or appending
"new" data. In this example I'm also swapping out the Entry status field
value with a new status field value because of the nature of what it's for.
Yes, the method is not overly generic because
of that but it's an example that you can tweak.
HTH,
-Eric
/**
*Adds the results (field/values) received from the external integration
system to the Entry retrieved
* from Remedy to update the entry in Remedy with latest data.
* @param Entry original the Entry to update in Remedy with
integration data.
* @param Map<\Integer,\String> attributes the Map returned from
field/value pair mapping retrieved from integration source
* @return Entry an Entry object with integration data appended
* @exception throws RuntimeException
*/
private synchronized Entry addResultsToEntry(Map<Integer,String> attributes,
Entry entry)
throws RuntimeException{
if(attributes != null && entry != null){
//map is our integration system to remedy mapping
Iterator<Map.Entry<Integer,String>> iter =
attributes.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry<Integer,String> x = iter.next();
//check to see if entry already has field id
and remove it so we can add the field id:value from the map
if (entry.containsKey(x.getKey())) {
entry.remove(x.getKey());
}
else{
//just add the fieldid:value to the
entry
logger.debug("adding value to return
entry: KEY: " + x.getKey() + " VALUE: " + x.getValue());
entry.put(x.getKey(),new
Value(x.getValue()));
}
}
}
//set the writer status (**which is necessary or the record
will continue to be read during polling**)
if(entry != null){
//remove existing status field from entry
if(entry.containsKey(ConfigParams.REM_STATUS_FIELD)){
entry.remove(ConfigParams.REM_STATUS_FIELD);
}
//add updated status back into entry
entry.put(ConfigParams.REM_STATUS_FIELD,
new
Value(ConfigParams.getConfigParameter(ConfigParams.WRITER_STATUS)));
}
return entry;
}
-----Original Message-----
From: Action Request System discussion list(ARSList)
[mailto:[email protected]] On Behalf Of John Baker
Sent: Friday, June 17, 2011 6:12 AM
To: [email protected]
Subject: Problem with JAVA API
Hello,
That is a rather odd problem. If you are fetching field 7, is it in the Entry
object? If so, I don't know why you see this error if you try calling setEntry.
Perhaps you should only get the fields you want to fetch, ie.
List<Integer> fields = new ArrayList<Integer>(); if (ACTIVIDADES_1!=null)
fields.add(536870934);
if ...
int[] campos= (int[])fields.toArray(new int[] {}); // not very nice syntax!
However, I would change the method entirely and pass in a map of field/values.
John
--
Single Sign On for BMC AR System
http://www.javasystemsolutions.com/jss/ssoplugin/bmcitsm
_______________________________________________________________________________
UNSUBSCRIBE or access ARSlist Archives at www.arslist.org
attend wwrug11 www.wwrug.com ARSList: "Where the Answers Are"
_______________________________________________________________________________
UNSUBSCRIBE or access ARSlist Archives at www.arslist.org
attend wwrug11 www.wwrug.com ARSList: "Where the Answers Are"