Validate lookup field - require value other than first item

I thought I would share something, and if there is a better way, please share. I have a list with a few Lookups that I wasn't able to require (since requiring them inserts the first option), and I was also not able to validate them (since they are Lookup
columns). Nevertheless, I needed a way to ensure a value was entered with some amount of thought.
The solution for me was to insert a Script Editor Web Part into the Default New Form and inserting a javascript snippet. On the list, on the ribbon List tab there is a Form Web Parts drop-down where the Default New Form can be found. Once you are there,
Adding a Web Part is pretty straight forward. The Script Editor Web Part can be found in Media and Content and you will insert your code after clicking on Edit Snippet.
The code, for me, needed to check a couple different Lookups for the Default "(None)" value when not set as a required field and block the Save and alert the user. In order to reference the correct Lookup fields I needed to use the IE Developer
tools (click on the cog, choose "F12 Developer Tools"), on the "DOM Explorer" tab select the left-most icon for the "Select element" tool and click on the Lookup field you need to reference.
Here is the code that worked for me:
<script language="javascript" type="text/javascript">
function PreSaveAction()
var e = document.getElementById('_x002e_034_x002d_Company_e721cbe9-05ee-41cd-8227-9fc32c09e8fc_$LookupField');
var strClient = e.options[e.selectedIndex].text;
var g = document.getElementById('_x002E_037_x002d_Contacts_ddad3e65-bd8a-4dec-9efc-fb9416a025b1_$LookupField');
var strContact = g.options[g.selectedIndex].text;
if(strClient=="(None)")
alert("***Client Field Required***\nPlease select a Client from the list or enter a New Client.");
return false;
if(strContact=="(None)")
alert("***Contact Field Required***\nPlease select a Contact from the list or enter a New Contact.");
return false;
return true;
</script>
I assume you can reference as many fields as you might require. Have fun with this, and I hope the solution is easily found for the next SharePoint Dev ;-).

Hi Alan,
Thank you for sharing this with us, and it will help others who have the same issue.
Victoria
Forum Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected]
Victoria Xia
TechNet Community Support

Similar Messages

  • On and iPad how to Allow User To Enter Custom Text  (Dropdown only) Enables users to enter a value other than the ones in the list.

    On an iPad, how do I :
    Allow User To Enter Custom Text
    (Dropdown only) Enables users to enter a value other than the ones in the list.'?

    Are you using the built-in Currency option under the Format tab? If so,
    what you're describing should not happen.

  • The document contains no posting lines with value other than zero

    Hi!
    We are having problems posting a invoice in MIRO. When entering the PO number we receive the error message "The document contains no posting lines with value other than zero".
    What could be the problem?
    /Anders

    Hi!
    The GR_BASEDIV is set in the PO. The PO is replicated from SRM where this flag has been set for no reason. Only GR and IV are set and we have implemented a note 1155266 so that Confirmation-Related IV will not be set.
    How come it is set anyway?
    Sincerely
    Anders

  • How to see the Table Names & Field Names by other than F1 help

    Hi Experts
       How to see the Table Names & Field Names by other than F1 help, & How to see the List of MM Table Names.
    Rgds

    The only option to see the active table/ field name is through F1 --> Technical Information. Apart from this, you can use any 3rd part application like GUIex (INbuilt in SAP ECC 6.0 ... can be activated by clicking on the tri-color button on the top right), but you need technical knowledge to understand the information. As far consolidated list of MM tables is concerned, SAP don;t provide you the same at one place, it experience and knowledge which help you in this regard. For your immediate reference MM tables are as under :
    EBAN  - Purchase Requisition 
    EBKN  - Purchase Requisition Account Assignment 
    EBUB   - Index for Stock Transport Requisitions for Materi
    EINA    - Purchasing Info Record: General Data 
    EINE     - Purchasing Info Record: Purchasing Organization D
    EIPA     - Order Price History: Info Record 
    EKAB   - Release Documentation 
    EKAN   - Vendor Address: Purchasing Document 
    EKBE    - History per Purchasing Document 
    EKBEH - Removed PO History Records 
    EKBZ    - History per Purchasing Document: Delivery Costs 
    EKBZH  - History per Purchasing Document: Delivery Costs 
    EKEH    - Scheduling Agreement Release Documentation 
    EKEK    - Header Data for Scheduling Agreement Releases 
    EKES     - Vendor Confirmations 
    EKET     - Scheduling Agreement Schedule Lines 
    EKETH   - Scheduling Agreement Schedules: History Tables 
    EKKI      - Purchasing Condition Index 
    EKKN    - Account Assignment in Purchasing Document 
    EKKO    - Purchasing Document Header 
    EKPA     - Partner Roles in Purchasing 
    EKPB     - "Material Provided" Item in Purchasing Document 
    EKPO    - Purchasing Document Item 
    EKPV    - Shipping-Specific Data on Stock Tfr. for Purch. D 
    EKRS    - ERS Procedure: Goods (Merchandise) Movements to b 
    EKUB    - Index for Stock Transport Orders for Material 
    EORD    - Purchasing Source List 
    EQUK    - Quota File: Header

  • Pass values other than string to applet

    Can you pass values other than strings via the <param> tag to an applet?

    I guess I didn't make my question clear enough. I know that you can pass integers and floats and what not because you can always call parsing functions. What i meant was can you pass java objects like Image objects, or session objects, things that cannot be parsed from strings

  • Inventory Value other Than Functional Currency

    How can we keep Inventory Valuation in Non - Functional Currency ?
    Scenario
    Ledger Currency = KES, Majority of the business for the client is from Exports, as the procurement happens in USD the can we retain the cost of the product in USD ?

    Hi Kiran
    Thanks for your reply
    I am required Little more help on this, please find the bellow example
    Example
    Ledger/functional Currency is INR
    bank currency is USD
    Currency conversion rate has been defined for the currency
    invoice is created in GBP, payment need to be make in GBP currency from USD account, because USD$ use for the GBD conversion, now my concern is bank is in USD currency that is other than functional currency, hence multi currency check box can not be enabled, since functional currency is INR so all transaction should be convert to INR for accounting and as multiple currency not allowed at bank therefore enable to make payment from same bank.
    Thanks
    Tarun

  • Why is it when I zoom at any value other than 25%, 50% or 100% my photoshop image looks pixelated?

    This is really bugging me and I can't get any work done...but I've had Photoshop for years so I know that if you zoom at any value other that 25%, 50%, 100%, 200% etc then the image loses some of it's quality, but up until today the image looked a little blurry when at a different zoom value, but now it looks really pixelated which makes the image looks really ugly and is making it hard to actually do anything. I have no idea what I did to change it to this, but now I can't change it back and I've tried everything I can think of.

    I've been using Photoshop for a decade and a half and have never, ever seen what you describe.
    Just a clarification in general, not necessarily referencing this or any other post:
    BOILERPLATE TEXT extracted from the FAQ:
    https://forums.adobe.com/thread/375816?tstart=0
    Do not be abusive or aggressive in your tone
    An aggressive, demanding, accusatory or abusive sounding post will often evoke an aggressive or abusive and unhelpful reply.
    Remember, you are not addressing Adobe here in the user forums.  You are requesting help from volunteers users just like you who give their time free of charge. No one has any obligation to answer your questions.
    We are not here to defend Adobe or to debate users.  We can only provide answers, solutions and workarounds.

  • How to show different value, other than whatever from database in a Field

    I have a repeatating frame (corresponding to one query).
    there are 6 fields (columns) in th RF.
    Now say in one of the column the database values are like 1,2,3,4 etc..
    I want to show 'ASSIGNED' corresponding to value 1, INPROGRESS corresponding to value 2 etc..
    Could you please tell me how can I do that?
    Regards

    Hi,
    You can create a formula column in your query and try below code. The formula column should have char as return data type
    IF :column = 1 then
       return 'ASSIGNED';
    ELSIF :column = 2 then  
       return 'IN PROGRESS';
    ELSIF :column = 3 then  
       return 'VALUE3';
    ELSIF :column = 4 then  
       return 'VALUE4';
    ELSE
       return 'VALUE5';
    END IF;Regards
    Manoj
    Edited by: ManojP on Jul 19, 2010 7:26 AM

  • 11.1.2 FR Column formula not working for rows other than first

    Hi All,
    I've a FR Grid with following layout
    Columns: Budget, Forecast, Var(Var being a formula col with the formula COL[A]- COL)
    Rows: Children of Total_Cost_Centre, Children of Total_Projects, ACC.10101
    Suppress MISSING on for row
    When i run the report, the rows show the valid combinations having data but the VAR column shows value only for the first combination while for rest of the rows it shows 0.
    The row selection is in one row only, not separate rows so there is no specific setting that could create the difference in results.
    Any help would be greatly appreciated.
    Cheers,
    Abhishek

    Hi All,
    I've a FR Grid with following layout
    Columns: Budget, Forecast, Var(Var being a formula col with the formula COL[A]-COL)
    Rows: Children of Total_Cost_Centre, Children of Total_Projects, ACC.10101
    Suppress MISSING on for row
    When i run the report, the rows show the valid combinations having data but the VAR column shows value only for the first combination while for rest of the rows it shows 0.
    The row selection is in one row only, not separate rows so there is no specific setting that could create the difference in results.
    Any help would be greatly appreciated.
    Cheers,
    Abhishek

  • How do I get a drop down menu to auto default to option selected a value other than the default written in the javascript?

    I use web based software where I have to select from a drop down menu a particular option. However, I only ever use 1 option. Sometimes as much as 100 times a day. Is there anyway to get Firefox to auto select the same option every time? I don't have access to the source code so I cant change <option selected="selected" value="">.

    A possibility would be a Greasemonkey script to do this automatically or a JavaScript bookmarklet to do it manually.
    You would need to remove the selected="selected" from the currently selected option and set that attribute for the wanted option.
    You can test the bookmarklet here:
    *https://developer.mozilla.org/en/HTML/Element/select
    <pre><nowiki>javascript:(function(){var d=document,s=d.getElementsByTagName('SELECT')[0],o=s.getElementsByTagName('OPTION'),S='selected',v='value1',i;for(i=0;O=o[i];i++){if(O.value==v){O.setAttribute(S,S);O.selected=true}else{O.removeAttribute(S);O.selected=false;}}})();</nowiki></pre>
    If there are more 'selects' then you need to adjust the element number [0] and you also need to adjust the value of the wanted option.

  • Not posssible to launch the slide show from other than first slide ?????

    Hi
    When I launch slideshow (in aperture 2.1.1 or 2.1.4) on a project (or an album) it always starts at the beginning. I have not found how to start on a particular picture (say in the middle). This is annoying when you have like 1000 pictures in an album or project and want to start the slideshow at say picture 250...
    any idea how to do that .... woks fine on iphoto...
    if not possible then it is a real drawback....
    thanks for your lights....

    Since the Slideshow only works on those images selected, simply open the 250th, click on Edit and choose Select to end. Assuming the images are in the sort sequence you wish, the Slideshow will start on the 250th (as an example).
    However, it will not double-back to pick up the first 249.
    Ernie

  • Can a setter store a value other than the one passed in?

    I have a set of nodes that each have a String 'name' property. I want to ensure that no two nodes have the same name, so whenever a name is set, I want to consult a global hash to see if the name has already been allocated. If so, I want my setter to choose a similar but unique name and set my node's name to that.
    If I do this, do I break the beans philosophy? Would utilities that use beans work incorrectly?

    If I understand the use of bean correctly; then no, you will not cause utilites to act badly "that use beans properly".
    I believe one of the uses of Setters is to do some type of validation on the information before it is accepted--your idea is well within that phylosophy.

  • Error "field required" in master-detail form with FORMS 10G!!

    I have a Master-Detail Form.
    When the cursor stay in detail block and i chage the master record with the mouse, clicking in scroll bar, i get error "field required".
    In Forms 6i, works fine!!

    Master block has more than one record displayed. When I click on any item in detail (except first one) and then click on different master record (return navigation to master block, but not current record) I have FRM-40202: Field must be entered on first item in detail block.
    I found that reason is this part of clear_all_master_details procedure (automatically created by Oracle Forms):
    IF :System.Cursor_Item <> startitm THEN
    Go_Item(startitm);
    Check_Package_Failure;
    END IF;
    Does any have same experience?
    Is it Oracle bug or I am missing something?

  • Validation on first item

    Hi,
    i am using apex_3.2.1.
    I have these items and i want to create validation on p1_item1 to check values.if the value entered in first item is
    exist into the database it shows the alert msg value already exist and control should not move to the next item.
    p1_item1
    p1_item2
    p1_item3
    p1_item4

    Hi,
    I want to focus the cursor on name item until the user
    not entered the Unique value. I am sending
    you login id and password.
    what I have done i am dispalying
    popup on item if user not entered the unique value in name item.
    I have implement this using ajex. name is the item on which
    i am displaying popup if value entered in name
    item exist into the database popup should raise and after click on ok
    button of popup cursor should point to the same item until user not entered the unique value.
    1)The problem is cursor not focus
    to the name item after display of the popup in case of incurrect value.
    2)it display The popup if i am click on the cancel button too.
    how could i resolve this problem. please help me to sort out this problem.
    TABLE NAME: LANGUAGE_MAS
    APPLICATION PROCESS: LANG_MAS\
    PAGE ITEM: TAB_DATA_TYPE
    i am sending you my application login id and password.
    Application No-51552
    page No -2 and 3
    URL ---apex.oracle.com
    Workspace   ---  DISCUSSION
    User Name  ----   [email protected]
    passowrd     ----      fuvubeEdited by: Vedant on May 19, 2011 10:17 PM

  • XSLT List View Web part with Inline Editing changing value for one field changes the other lookup field

    Hi
    It's a bit of a weird one. In an XSLT List View web part when Inline editing is enabled if I change the date column, it changes the lookup field column as well. This behavior only occurs if the lookup list has more than 20 entries. Below 20 and we are
    OK.
    Let me explain by example:
    MileStones List - Having more than 20 items
    Tasks List - having a lookup to the Title field from MileStones list. Also having a due date field.
    Simple web part page with one XSLT List View web part for Tasks having inline editing enabled.
    When I edit the first record's due date and press enter (which saves the changes and moves onto next record) and change the due date on second record without even touching the MileStone field. Press enter to commit changes and you see the milestone changing
    on first record!
    The wierd thing is that if the MileStone list has less than 20 items all works as expected.
    Any pointers will be appreciated
    Thanks

    Hi,
    This is a known limitation when working with complex fields like Lookup field.
    A workaround is that we can avoid using the inline edit feature when there are
    complex fields in a list.
    You can take a look at this KB from Microsoft Support to get more details:
    http://support.microsoft.com/kb/2600186/en-us
    A similar thread for your reference:
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/3d369611-ee79-4b5c-86bb-c0f3878cd746/standard-list-view-with-inline-editing-lookup-column-copies-preceding-or-following-items-related?forum=sharepointgeneralprevious
    Thanks
    Patrick Liang
    TechNet Community Support

Maybe you are looking for

  • Can not update BIOS R830-14U

    Notebok Satellite R830-14U (part ? PT32LE) with BIOS 2.70 & EC 1.10 after upgrade Intel Management Engine Interface v.7.1.52.1176 i can not update BIOS - error "This computer is not supported" http://ru.computers.toshiba-europe.com/innovation/dodrive

  • How to install j2ee sun app server 8.0 in debain linux

    hi guys i am new to linux and i have downloaded the j2ee sun app server 8.0(linuxversion) from sun.java in sun.java documentation says first we have to change the mode to excecutable then he is saying to do this 1. To run the installation program tha

  • Application Authentication

    Hi, All I have some question about MHP Application Authentication, please help me answer them, thanks 1. What's the difference or relationship between "Application Authentication" and "File Authentiction"? 2. For mhp specification 1.03, File Authenti

  • Stripped Screws

    I replaced the HDD in my macbook pro (2010 i5 unibody); unfortunately while putting the case back together I stripped a screw. It is still sticking out slightly. If I brought the laptop into an Apple Store, would they assist me in either tightening o

  • Has anyone exported time history data from Labview to B&K Pulse ?

    Hello I use a Bruel & Kjaer Pulse 9 system for the NVH analysis of data acquired from a DAT tape recorder. I know about the CompactRIO and I can see its potential as an ultra-portable digital data logger, for field testing. It could for example recor