on 10-02-2007 6:19 AM
Hi All,
I am trying to create a new Qualified link with the Main table Record,
Following is the code that i have used:-
//Creating empty record in Qualifed table Request
//Adding No Qualifiers
Record qualified_record = RecordFactory.createEmptyRecord(new TableId(<TableId>));
try {
qualified_record.setFieldValue(new FieldId("F541_62555"), new StringValue(<StringValue>));//Adding No Qualifier
}
catch (IllegalArgumentException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
catch (MdmValueTypeException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
//Creating Record in Qualified table
CreateRecordCommand create_command = new CreateRecordCommand(connections);
create_command.setSession(sessionId);
create_command.setRecord(qualified_record);
try
{
create_command.execute();
}
catch(Exception e)
{
System.out.println(e.toString());
}
RecordId record_id = create_command.getRecord().getId();
//Adding the new record to Qualifed Lookup value and setting the Yes Qualifiers
QualifiedLookupValue lookup_value = new QualifiedLookupValue();
int link = lookup_value.createQualifiedLink(new QualifiedLinkValue(record_id));
//Adding Yes Qualifiers
lookup_value.setQualifierFieldValue(0 , new FieldId(<FieldID of Yes Qualifier>) , new StringValue(<StringValue>));//Here since there is already an existing Qualified link for the particular record , so if i mention 1 as the first parameter it throws exception and if i write 0 as the first parameter it deletes the first link n creates a new Qualified link
Record record = factory.createEmptyRecord(new TableId(1),getRecordID(connections , sessionId ,<MaterialID> , <FieldId of MaterialID,new String("T1")));
try
{
record.setFieldValue(new FieldId(<FieldID of Qualified field>), new QualifiedLookupValue(lookup_value));
}
catch(Exception e)
{
e.printStackTrace();
}
ModifyRecordCommand modify_command = new ModifyRecordCommand(connections);
modify_command.setSession(sessionId);
modify_command.setRecord(record);
modify_command.setModifyAnyway(true);
try {
modify_command.execute();
} catch (CommandException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Can anybody help me with this code??Where am in goin in creating a new qualified link in addition to the existing links??
Thanks
Namrata
Hi Namrata,
The mistake you are doing is for one main table record if you want to create more than one qualified link you need to have only one QualifiedLookupValue.Multiple objects of QualifiedLookupValue will either replace the previous link or just add non qualifiers.So even when you update a link do update it with the fetched QualifiedLookupValue by casting the returned Value object.Also if you want to craete a new link id than pass it as the first argument
at the following line of your code.
lookup_value.setQualifierFieldValue(0 , new FieldId(<FieldID of Yes Qualifier>)
I hope it solves your problem.
Thanks
Vinay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.