cancel
Showing results for 
Search instead for 
Did you mean: 

How to add record in Qualified table using MDM Java API

Former Member
0 Kudos

Hi experts,

I am trying to add a record into a Table.

but I am facing the problem in setFieldValue method.

//Getting Field-ID to pass in setFieldValue() method.

FieldId[] fields = new FieldId[6];

fields[0] = repSchema.getFieldId("GTINs", "Description");

fields[1] = repSchema.getFieldId("GTINs", "Unit_Descriptor");

fields[2] = repSchema.getFieldId("GTINs", "GTIN");

fields[3] = repSchema.getFieldId("GTINs", "Alternate_Item_Classifications");

fields[4] = repSchema.getFieldId("GTINs", "Country_Of_Origin");

fields[5] = repSchema.getFieldId("GTINs", "Bar_Coded");

Record rec = RecordFactory.createEmptyRecord(mainTableId);

rec.setFieldValue(fields, );

but I am not getting how to assign the value to these fields using MDMvalue Interface.

Can anyone provide me the code sample or Code flow so that I can do this.

Plz help me it'll be great help for me.

Thanks

Tarun

Edited by: Tarun Sharma on Feb 4, 2008 11:39 AM

==========================================================================================

Hi Gurus

I found the way to add the MDMValue in setFieldValue Method.

we can set like this:

setFieldValue(<fieldId object like fieldId[], <MdmValue like this> new StringValue("ABC"));

Now I am facing problem in adding value to lookup flat table.

According to the setFieldValue method we can assign the loookup like this:

setFieldValue(<fieldId[0]>, new LookpValue(<here we have to pass the recordID of lookup table>);

so I want to know how I can pass the recordId of lookup table here.

Please suggest.

Thanks

Tarun Sharma

Edited by: Tarun Sharma on Feb 4, 2008 3:15 PM

Edited by: Tarun Sharma on Feb 4, 2008 3:25 PM

Edited by: Tarun Sharma on Feb 8, 2008 6:58 PM

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi experts,

Now, I want to add record to qualified table.

The Sceinario is:

1. Main table<M_Table> contais a Qualified field<Q_Field> which is qualified table.

2. This qualified table<Q_Table> contains a Text field<T1> and a Lookup field<L_Field> which is a lookup [Flat] table.

3. This lookup table<L_Table> contain 2 text field<T1>and <T2>.

Can anyone suggest me the steps or provide me the sample code for adding record in the above

mentioned hierarchy.

Points will be rewarded.

Thanks

Tarun Sharma

Former Member
0 Kudos

Hi Tarun ,

U must start from point 3 ,then point 2 and 1.

From point 3 and 2 U see the solution above.

To insert qualifiedValue to main u get id or the record of qualified and then add it to main table like this:

QualifiedLookupValue qlv= new QualifiedLookupValue();

qlv.createQualifiedLink(<IdOfRecordOfQualifiedTable>);

mainRec.setFieldValue(<IdOfQualifiedField>,qlv);

This is for adding qualified (non multivalue) field to main table.

Regards.

Andrea

Former Member
0 Kudos

Hi Andrea,

I tried your suggestion but now i am getting Type Mismatch Error.

Please suggest me what I can do?

//TableId for Lookup[Flat].

TableId lookupTableId = repSchema.getTableId("Return_Goods_Policies");

FieldId[] ReturnGoodsPolicyTableIdFields = new FieldId[1];

ReturnGoodsPolicyTableIdFields[0] = repSchema.getFieldId("Return_Goods_Policies", "Name");

Record recLookup = RecordFactory.createEmptyRecord(lookupTableId);

try{

recLookup.setFieldValue(ReturnGoodsPolicyTableIdFields[0], new StringValue("New_Brand"));

}catch(Exception ex){

System.out.println(ex);

}

//Creating Record in Qualified Table - Request Details

CreateRecordCommand createLookupcommand = new CreateRecordCommand(simpleConnection);

createLookupcommand.setSession(session);

createLookupcommand.setRecord(recLookup);

createLookupcommand.execute();

//Getting the recordId of Lookup record.

RecordId lookupRecordId = createLookupcommand.getRecord().getId();

//Table Id for Qualified table.

TableId qualifiedTableId = repSchema.getTableId("Ext_Hardlines");

FieldId[] ExtHardlinesFields = new FieldId[3];

ExtHardlinesFields[0] = repSchema.getFieldId("Ext_Hardlines", "Name");//Text

ExtHardlinesFields[1] = repSchema.getFieldId("Ext_Hardlines", "Pieces_Per_Trade_item");//Integer

ExtHardlinesFields[2] = repSchema.getFieldId("Ext_Hardlines","Return_Goods_Policy");

Record recQualified = RecordFactory.createEmptyRecord(qualifiedTableId);

try{

recQualified.setFieldValue(ExtHardlinesFields[0], new StringValue("Qualified Value"));

recQualified.setFieldValue(ExtHardlinesFields[1], new StringValue("Qualified Description"));

recQualified.setFieldValue(ExtHardlinesFields[2], new LookupValue(lookupRecordId));

}catch(Exception ex){

System.out.println(ex);

}

//Creating Record in Qualified Table - Request Details

CreateRecordCommand createQualifiedCommand = new CreateRecordCommand(simpleConnection);

createQualifiedCommand.setSession(session);

createQualifiedCommand.setRecord(recQualified);

createQualifiedCommand.execute(); I am getting this Type match here, but i m not getting what mistake i did.

RecordId qualifiedRecordId = createQualifiedCommand.getRecord().getId();

//Adding to Main Table

TableId mainTableId = repSchema.getTableId("GTINs");

FieldId[] gtinsFields = new FieldId[1];

gtinsFields[0] = repSchema.getFieldId("GTINs","Ext_Hardlines");

Record recMain = RecordFactory.createEmptyRecord(mainTableId);

//Adding the new record to Qualifed Lookup value and setting the Yes Qualifiers

QualifiedLookupValue qualifiedLookupValue = new QualifiedLookupValue();

qualifiedLookupValue.createQualifiedLink(qualifiedRecordId);

try{

recMain.setFieldValue(gtinsFields[0], new QualifiedLookupValue(qualifiedLookupValue));

}catch(Exception ex){

System.out.println(ex);

}

CreateRecordCommand createCmd = new CreateRecordCommand(simpleConnection);

createCmd.setSession(session);

createCmd.setRecord(recMain);

createCmd.execute();

Could you help me out?

Thanks

Tarun

Former Member
0 Kudos

Hi Andrea,

Thanks for your great help.

As I asked you. Could you let me know the process of adding value to Qualified table.

Could you give the sample code or flow for this program.

Once again thanks for your help.

Thanks

Tarun

Edited by: Tarun Sharma on Feb 6, 2008 4:39 PM

Edited by: Tarun Sharma on Feb 6, 2008 5:18 PM

Former Member
0 Kudos

hi

U must insert record in lookup table first:

Record rec = RecordFactory.createEmptyRecord(<LookUPTableId>);

set value:

rec.setFieldValue(<FieldIdOfLooukupTable>,new MdmValue());

Then u insert a lookUpValue in Main Table

recordOfMain.setFieldValue(<LookUpFieldOfMain>,new LookupValue(rec.getId()));

Regards

Andrea