on 01-28-2010 2:58 PM
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.