Highlighted
forumadmin Absent Member.
Absent Member.
9237 views

webservices (mashups): updating an item with extended field


Discussion posted 10/5/09 by Jerry Davis
Details:

I have the following code, that updates an item, with a regular field in it (description), but I can't seem to find a way to set the value of an extended field.
#!/usr/bin/env perl
# sbmupdate.pl
# update an item in bizmu
#use SOAP::Lite; # <-- comment out for debug output
use SOAP::Lite +trace; # <-- uncomment for debug output
#validate arguments
if (@ARGV < 4)
{
print "usage: sbmupdate.pl servername userid password itemid field=value {field=value ...}\n";
exit 1;
}
my ($inserver, $inuserid, $inpassword, $initemid, @infields) = @ARGV;
# get instance of SOAP::Lite object
my $soap = SOAP::Lite
-> uri('urn:aewebservices70')
-> proxy("http://${inserver}/gsoap/gsoap_ssl.dl...)
-> readable(1)
-> on_fault(sub {
my($soap, $res) = @_;
die ref $res ? $res->faultstring : $soap->transport->status, "\n";
}
);
# set up for login, have to do it differently on windows
# than either linux or cygwin.
$nuserid = 'userId';
$npwd = 'password';
$nhost = 'hostname';
$nauth = 'auth';
$nuval = 'IsUserValid';
if ($^O =˜ /win32/i) {
$nuserid = "namesp1:$nuserid";
$npwd = "namesp1:$npwd";
$nhost = "namesp1:$nhost";
$nauth = "namesp1:$nauth";
$nuval = "namesp1:$nuval";
}
my $p_userid = SOAP::Data->name($nuserid)->value($inuserid)->type('');
my $p_password = SOAP::Data->name($npwd)->value($inpassword)->type('');
my $p_hostname = SOAP::Data->name($nhost)->value($inserver)->type('');
# login
my $p_auth = SOAP::Data
->name($nauth => \SOAP::Data->value(
$p_userid,
$p_password,
$p_hostname,
)
);
my $itemid = SOAP::Data->name("itemID")->value($initemid)->type('');
my $options = SOAP::Data->name("responseOptions")->value("SECTION:ALL")->type('');
# call the function for GetItemm
my $som = $soap->GetItem($p_auth, $itemid);
# print the results of the Items ( Title - Description - State)
my $item = $som->valueof('//GetItemResponse/return');
print "title = $item->{title}\n";
print "descr = $item->{description}\n";
print "state = $item->{state}\n";
# now update the item's description
my $value = $item->{description}; # get old value
$value .= " Updated via script sbmupdate.pl"; # add to the end, to show something done
# update needs the genericItem (specifically what record is being updated)
my $genericitem = SOAP::Data->name("genericItem" => \SOAP::Data->value(
SOAP::Data->name("itemID" => $initemid)));
# now create the soap mod item
my $smoditem = SOAP::Data->name("item" => \SOAP::Data->value(
$genericitem,
SOAP::Data->name("description" => "$value: is updated by $inuserid\n")
)
);
# SOAP::Data->name("contact_numbers" => "updated by script")));
print "updating item: $initemid\n";
my $transitionid = SOAP::Data->name("transitionId")->value("0")->type(''); # use default
# now -- update the item
$som = $soap->UpdateItem($p_auth, $smoditem, $transitionid);

0 Likes
1 Reply
forumadmin Absent Member.
Absent Member.

Re: webservices (mashups): updating an item with extended field


Comment posted 10/5/09 by Jay Yan

To set the value of an extended field, you need:
1. add one element in the extendedFieldList array, which is at the same level of the other regular fields;
2. set the name of that element to the name of the field.
3. set the value/displayValue or value/internalValue of that element to the value you want to set. (To use displayValue or internalValue depends on your business logic.)

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.