cancel
Showing results for 
Search instead for 
Did you mean: 

update record in mdm server using java api

Former Member
0 Kudos

i need to update a record in vendors table of MDM server.i am new to MDM so it would be great if i can get a code to update record in vendors table of mdm server.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Utkharsh,

You can use CatalogData's UpdateRecord method for doing this.

I would not have code for the same handy but the steps to do this would be:

1. Create A2IFields array and fill it with A2IField(s) that you want to update.

2. Get the Vendor record ID for which you want to update the data.

3. Get the change stamp for the Vendor record.

4. Call updateRecord method of CatalogData class.

Hope this helps.

Regards,

Mausam

Former Member
0 Kudos

Hello:

You can use this method:

CatalogData.UpdateRecord(Table : String, RecordID : int,

ChangeStamp : int, Fields: A2iFields, [ParentID : int =

-1, Position : int = -1]) : int


Argument          Description
Table              Name of table where record is to be updated
RecordID           RecordID of record to be modified
ChangeStamp        Last known change stamp of the record
Fields             Collection of Field objects containing names and values of fields to be updated
ParentID           The parent ID in the case where the table is an hierarchy table, otherwise -1
Position           The position in the case where the table is an hierarchy talbe, otherwise -1
Return Value       New change stamp for the record

And this is an example:


import a2i.common.*;
import a2i.core.*;
int recordId = 798;
ResultSetDefinition rsd = new
ResultSetDefinition("Products");
A2iResultSet rs;
A2iIntArray ids = new A2iIntArray();
A2iFields fields = new A2iFields();
ids.Add(recordId);
rs = catalogData.GetRecordsById(rsd, ids);
fields.Add(
new A2iField("Part Number", new Value("ABC-123")));
int newId = catalogData.UpdateRecord("Products",
recordId, rs.GetChangeStampAt(0), fields);
System.out.println(newId);

I hope that helps

Alejandro

Answers (2)

Answers (2)

Former Member
0 Kudos

But now I get this error message:

Login method has not been successfully called.

Regards,

AA

Former Member
0 Kudos

I get the following error when I run your example in line of the code:

rs = catalog.GetRecordsById(rsd, ids);

java.lang.NullPointerException

Please advise.

Former Member
0 Kudos

Azim,

You have to first initialize your Catalog before you can call the GetRecordsBy.

CatalogData catalog = new CatalogData();

try

{

// try logging in

int resultLogin = catalog.Login(hostname, port, uname, pwd, language, mincon, maxcon, timeout,logFile);

if (resultLogin != RC.RC_OK)

{

System.out.println("Error logging into MDME server: " + RC.GetTextForError(resultLogin) + " (" + resultLogin + ")");

return null;

}

System.out.println("Logged into MDME server.");

}

catch (Exception e)

{

e.printStackTrace();

}