on 12-28-2009 4:54 AM
Hi,
In the following code, How do i get "R2" value?? Can anyone send me the code to get that value.
I am trying to build an interface for Bulk Upload where i read values from an excel file and create records in Products table where there are lot of lookup fields. I read the value from the excel sheet and need to search that value in lookup table to retreive the recordId right? Can you send me that code?
RecordId recordId = new RecordId("R2");
MdmValue requestValue = new LookupValue(recordId);
If you can give me code snippet for CreateRecordsCommand to create multiple records at a time, it will be great.
Your help is really appreciated.
Thanks
Vijay
Hi Vijay,
You will get the RecordId such as R2 by searching the lookup table that you are pointing to from the main table. Check out the RetrieveLimitedRecordsCommand in the javadocs.
-Greg
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Create Connection and start up
Create
Modify:
Search
Hi Vijay,
You have to perform a search on the lookup table and get the corresponding record ID, please find some sample codes as below,
TableID tid = schema.getTableId("<lookup table Code>");
FieldID Fid = schema.getFieldId("<lookup table Code>","Field ID");
Search obj_Search = new Search(tid);
Search .addSearchItem(new FieldSearchDimension(Fid),new TextSearchConstraint("<input string>", TextSearchConstraint.EQUALS));
RetrieveLimitedRecordsCommand retrieve_Table_records_cmd =
new RetrieveLimitedRecordsCommand(connection);
retrieve_Table_records_cmd .setSearch(MDM_Search);
retrieve_Table_records_cmd .setResultDefinition(rsd);
retrieve_Table_records_cmd .setSession( usersession);
try {
retrieve_Table_records_cmd .execute();
} catch (CommandException e5) {
// TODO Auto-generated catch block
e5.printStackTrace();
}
RecordID Lookup_RID = retrieve_Table_records_cmd.getRecords().getRecord(0).getId();
Best regards,
Arun prabhu S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Arun,
I tried the code you mentioned, but it didn't work. I tried with the following code and it worked.
ResultDefinition rsd = new ResultDefinition(LookupTableid);
rsd.addSelectField(LookupFieldid);
StringValue [] val = new StringValue[1];
val[0] = new StringValue(Exlvalue);
RetrieveRecordsByValueCommand val_command = new RetrieveRecordsByValueCommand(connecPool);
val_command.setSession(usrSessionIdAdm);
val_command.setResultDefinition(rsd);
val_command.setFieldId(LookupFieldid);
val_command.setFieldValues(val);
try {
val_command.execute();
} catch(Exception e) {
wdComponentAPI.getMessageManager().reportWarning("Problem in executing LookupTable: " + e.getMessage());
}
RecordResultSet result_set = val_command.getRecords();
RecordId id = null;
if(result_set.getCount()>0) {
for(int i = 0 ; i < result_set.getCount() ; i++) {
id = result_set.getRecord(i).getId();
}
}
//wdComponentAPI.getMessageManager().reportWarning("Record Id: " + id.getIdValue());
return id;
Thanks
Vijay
Hi
Below Code snippet should help you creating records in any MDM Main tables
CreateRecordsCommand createRecComm = new CreateRecordsCommand(connections);
createRecComm.setSession(userSessId);
createRecComm.setRecord(records);
try {
createRecComm.execute();
success = true;
wdComponentAPI.getMessageManager().reportSuccess(
"After inserting record: record:" + rec1);
} catch (CommandException exp) {
wdComponentAPI.getMessageManager().reportException(
exp.getLocalizedMessage(),
false);
success = false;
} catch (Exception exp) {
wdComponentAPI.getMessageManager().reportException(
exp.getLocalizedMessage(),
false);
success = false;
}
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.