Asked by:
how to display only the non selected values in lookup in crm 2011

Question
-
While creating a new record by selecting some record from the lookup field and save the record.when i open the new form the already selected record should not be displayed in the lookup items.
Best Regards,
Meena.
Thursday, June 27, 2013 10:52 AM
All replies
-
Hi,
On Page load check if the FORM_Type is Update.Then write your logic to clear the selected lookup.But remember every time when a record is open it will not show the saved value due to your logic to clear the field.
Regards,
Yusuf
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Thanks and Regards, Mohammad Yusuf Ansari http://microxrm.blogspot.in
Thursday, June 27, 2013 12:01 PM -
Hi,
Thank you for your response can u kindly give me a brief explain regarding your post.
Best Regards,
Meena.
Thursday, June 27, 2013 12:05 PM -
You can do something like below
function Form_Onload() { // When Form Type = Update if (Xrm.Page.ui.getFormType() == 2) { //"new_lookupid" replace with your lookupname if (Xrm.Page.getAttribute("new_lookupid").getValue() != null) Xrm.Page.getAttribute("new_lookupid").setValue(null); } }
Regards,
Yusuf
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Thanks and Regards, Mohammad Yusuf Ansari http://microxrm.blogspot.in
Thursday, June 27, 2013 12:11 PM -
This is not exactly what i need.Please kindly go through the scenario.First i will create a record and selected say "ABC" record from the lookup field and save and close the record now i wil click on the new button to create another record and when i want to select a record from the lookup field the already selected record i.e."ABC" should not be displayed in the list of lookup filed item exact that record"ABC" rest of the records can be displayed.
Best Regards,
Meena.
Thursday, June 27, 2013 12:17 PM -
Hi,
I would like to suggest you to apply validation onSave event of the entity.
Check if the selected record say "ABC" is already used.You implement it by ODATA query.Below is a hint
function onSave(context) { if (context != null && context.getEventArgs() != null) { var saveMode = context.getEventArgs().getSaveMode(); if(saveMode == "1") { // Write your logic here using ODATA } } }
Regards,
Yusuf
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Thanks and Regards, Mohammad Yusuf Ansari http://microxrm.blogspot.in
Thursday, June 27, 2013 12:34 PM