cancel
Showing results for 
Search instead for 
Did you mean: 

How to insert a record into qualified lookup and get non-qualifier value

Former Member
0 Kudos

Hi

I need code to insert a record in Qualified Lookup Table where the non-qualifier is a record of type Country. Other fields are qualifiers.

I tried using QualifiedLookupValue.createQualifiedLink(). However, this only helps to insert in the qualifier values, how can I insert the non-qualifier (Country) value?

There was an earlier thread but there is no solution. Could any one give the solution for this.

-Sai

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Sai,

Creating a new record qualified lookup table is same as creating a record in main table.

you have to use CreateRecordCommand...

1. Record record = RecordFactory.createEmptyRecord("Table ID");

2. record.setFieldValue("Field ID","Field Value");

3.

CreateRecordCommand cmd = new CreateRecordCommand(context);

cmd.setRecord(record);

cmd.execute();

return cmd.getRecord().getId();

} catch (Exception e) {

}

if you want to insert value in qualifiedLookup field for Main table record , you need use below code.

qualifiedLookupValue = (QualifiedLookupValue) mainRecord.getFieldValue("Qualified Lookup field ID");

int index = qualifiedLookupValue.createQualifiedLink("Record Id from Qualified table"); //retrieve record id from Qualified table..

qualifiedLookupValue.setQualifierFieldValue(index, "Qualifier Yes field id", "Qualified yes field value);

mainRecord.setFieldValue("Qualified Lookup field ID", qualifiedLookupValue);

Hope it helps you...

Thanks & Regards,

Veeru.

Former Member
0 Kudos

Hi Veeru,

I am doing more or less same as you mentioned, but it is creating an entry into QualifiedLookup table.

Here is my code, not sure what is that I am not doing correctly.

QualifiedLookupValue qlv = (QualifiedLookupValue) emptyRecordProduct.getFieldValue(schema.getField("Products", "Prices").getId());

RecordId recIdRefPriceQual=null;

recIdRefPriceQual=getQualRPRecordId("RP") ;

recIdCurrency = this.getRecordID(connecPool,usrSessionIdAdm,"EUR",LookupFieldId,LookupTableId);

System.out.println("recIdCurrency:" + recIdCurrency + ":recIdRefPriceQual" + recIdRefPriceQual);

Calendar calRefPriceStartDate = null, calRefPriceEndDate=null;

calRefPriceStartDate = getCalendarFromDateLiteral("01/10/2010");

calRefPriceEndDate = getCalendarFromDateLiteral("12/12/3999");

int linkId =qlv.createQualifiedLink(recIdRefPriceQual);//////

if(recIdCurrency!=null)qlv.setQualifierFieldValue(linkId, schema.getField("ReferencePrices", "Currency").getId() , new LookupValue(new RecordId(recIdCurrency)));

if(calRefPriceStartDate!=null)qlv.setQualifierFieldValue(linkId, schema.getField("Prices", "StartDate_ReferencePrice").getId() , new DateTimeValue( calRefPriceStartDate) );

if(calRefPriceEndDate!=null)qlv.setQualifierFieldValue(linkId, schema.getField("Prices", "EndDate_ReferencePrice").getId() , new DateTimeValue( calRefPriceEndDate) );

qlv.setQualifierFieldValue(linkId, schema.getField("ReferencePrices", "ListPrice").getId() , new DoubleValue(Double.parseDouble("1.0")));

record.setFieldValue( schema.getField("Products", "Prices").getId(),qlv);

Please let me know.

Thanks

-Sai

Former Member
0 Kudos

Hi Veeru,

The first line has a variable name different when I posted the reply, but it is not the problem.

QualifiedLookupValue qlv = (QualifiedLookupValue) record.getFieldValue(schema.getField("Products", "Prices").getId());

Thanks

-Sai

Former Member
0 Kudos

Hi Sai,

If i am understand correctly,

every time when you are populating qualified lookup field value in main table record, new record is getting inserted in Qualified Lookup table also.

Please check the method recIdRefPriceQual=getQualRPRecordId("RP") ;

I think every time you call the above given method, it might be inserting a new record in Qualified table.

You have to include the logic to check given qualified- no field value already exist in Qualified table, if yes return that record id instead of creating a new record again in Qualified table.

1.Check record is already exist in Qualified table

2. if Yes , take existing record id and use in createQualifiedLink method

3. if No, create new record in Qualified table and use recordid of new record in CreateQualifiedLink method.

Thanks & Regards,

Veera.

Answers (0)