cancel
Showing results for 
Search instead for 
Did you mean: 

Java MDM API How to add Blob field to the Table

sergey_tuzov
Explorer
0 Kudos

I have add TextBlobRecord row to the Text Block Table, and now I would like to add the row reference

to the anothe table filed which has type Lookup [Text Block].

How to do this, and which MmdValue type should I use?

recordEx.setFieldValue(schema.getFieldId("MDM_BUSINESS_PARTNERS", "ADDRESS"), ? );

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You have to use LookupValue type.first you need to get record id from Text Blocks table and has to create instance of LookupValue. ....Please see the code below.....

RecordId recordId = new RecordId("R1");

MdmValue mdmValue = new LookupValue(recordId);

record.setFieldValue("Field Id",mdmValue);

Hope it helps..........

Regards,

Veeru.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Sergey,

You may use the below code for creating a record in Text Blocks table and then attach it to main table as we do for Lookup values.

	CreateRecordCommand objCreateRecordCommand = new CreateRecordCommand(objConnectionManager.getConnectionAccessor());
	TextBlobRecord objTextBlobRecord = RecordFactory.createEmptyTextRecord(new TableId(strTextBlockTableId));
	objTextBlobRecord.setBinary(objBinaryValue);
	objTextBlobRecord.setDataGroupId(new GroupNodeId(1));
	objTextBlobRecord.setDescription(new StringValue("Attached file reference"));
	objTextBlobRecord.setDataSize(new StringValue(fileBuf.length+""));
	objTextBlobRecord.setHasThumbnail(new StringValue("false"));
	objTextBlobRecord.setName(new StringValue(strUploadFileName));
	objTextBlobRecord.setCode(strUploadFileName);
	objTextBlobRecord.setOriginalName(new StringValue(strUploadFileName));
	objTextBlobRecord.setSource(new LookupValue(new RecordId(1)));
	objCreateRecordCommand.setRecord(objTextBlobRecord);
	objCreateRecordCommand.setSession(strUserSessionId);
	try 
	{
		objCreateRecordCommand.execute();
	} 
	catch (CommandException e) 
	{
		throw e;
	}

Hope this helps!!

Cheers,

Arafat