This discussion is archived
6 Replies Latest reply: May 20, 2013 7:36 AM by Najdawi RSS

How to set field required on Checkin page depending on another field

Najdawi Newbie
Currently Being Moderated
Good Day,
I have the following case in my UCM profile:
- there is a field; configured to view have two values (1: Internal , 2: External); this field is required
- there are two fields they are dependant on the above field (xInternal, xExternal); these two fields are edit.
- i control them in a custom component that i did, when i select Intenal from the list the xExternal field disappear, an when i select External from the list the xInternal field disappear.

What i want to do is:
- when i select Internal from the list, i want to make the xInternal field to be required (i want to get alert to that this filed is required and its value must be specified); the field that will be set to required (xInternal or xExternal) will depend on the selected value from the above field; above list.


Regards
  • 1. Re: How to set field required on Checkin page depending on another field
    jiri.machotka Guru
    Currently Being Moderated
    Profiles/Rules do not support client-side operations.

    OOTB, you can create two profiles; one for Internal, where the value 1: Internal will be selected for the first field, and xInternal required/xExternal hidden, and vice versa. Alternatively (if xInternal and xExternal have the same type), you could have just one field, make it mandatory, but change its label (thus, meaning).

    Everything above that will require customization (javascript) or at least 'Use Custom Include' (see http://docs.oracle.com/cd/E23943_01/doc.1111/e10978/c04_metadata.htm and/or Dynamically changing Restricted List for an example of usage)
  • 2. Re: How to set field required on Checkin page depending on another field
    Najdawi Newbie
    Currently Being Moderated
    Thanks for your reply,

    i tried to use the following piece of code in my page:
    <$external="xExternal"$>
    document.forms.Checkin.<$external$>.required = true;
    alert(document.forms.Checkin.<$external$>.required);

    and once i try to check in a document i got the alert message of the xExternal field says "true" ==> the required property is true, but this change didn't reflected on the field itself, even i got required = true.

    Any suggestion or still not possible to customize this case.

    Regards.
  • 3. Re: How to set field required on Checkin page depending on another field
    jiri.machotka Guru
    Currently Being Moderated
    I'm afraid I don't follow you.

    Where did you use the code? 'My page' is unclear to me.
  • 4. Re: How to set field required on Checkin page depending on another field
    Najdawi Newbie
    Currently Being Moderated
    the code will be used within my custom component in the resource.htm page.

    i use the <@dynamichtml std_option_list_entry@> in order to perform my check. in this resource file i control the appearance and hidden of fields, the page loo like this:


    <@dynamichtml std_option_list_entry@>
    <$include std_prepare_option_list_id$>
         <$if isFieldTreeEdit$>
         <span id="<$optionListId$>_span"></span>
         <script type="text/javascript">
         registerTreeControl("<$js(optionListId)$>", "<$js(fieldName)$>");
         </script>
         <$else$>
         <$if not isStrictList or isMultiOption$>
         <label class="hidden" for="<$optionListId$>"><$lc("wwOptionsForField", fieldCaption)$></label>
         <$endif$>
         <span id="<$optionListId$>_span">
         <select name="<$fieldName$><$if isMultiOption or not isStrictList$>_Options<$endif$>" id="<$optionListId$>" <$if fieldDisabled$>disabled="disabled"<$endif$>
              onchange="<$strTrimWs(inc('std_on_option_change'))$>;<$strTrimWs(inc('custom_on_option_change'))$> " <$include enter_for_search$>>
    <$if addEmptyOption or not optionsAllowPreselect$><$inc('clearOptionsAllowPreselect')$><option <$if not #active.emptyOptionLabel$>class="idcNoSelection" label="<$lc('wwNoSelection')$>"<$endif$> value=""><$if #active.emptyOptionLabel$><$#active.emptyOptionLabel$><$else$> <$endif$></option><$endif$>
         <$if fieldOptionListScript$><$strTrimWs(eval(fieldOptionListScript))$><$endif$>
         </select>

    <$if hasOptionList and not noSchema$><$include js_build_option_list$><$endif$>
         <$if isMultiOption and isStrictList$><$include std_strict_optionlist_display_hook$><$endif$>
         <$optionListId = ""$>
    <@end@>

    i want here to check if the field/list value (1:Internal , 2: External) and based on the selected value i want to set the xInternal or xExternal field to be required.
    Is that possible here to set the field required property?
  • 5. Re: How to set field required on Checkin page depending on another field
    jiri.machotka Guru
    Currently Being Moderated
    Got you now. It'd also help me to see how you tried to combine the two pieces together. However, to your question
    Is that possible here to set the field required property?
    First, take a look at a piece of source code of one standard field, which is always required, if present - Primary File
    <tr id="primaryFile-38858_row"
     class="idcRowClass-primaryFile idcRequiredEntry">
         <td class="idcFieldCaption idcCheckinUpdateCaption"><label for="primaryFile-38858">
    * Primary File<span class="hidden">(Required:)</span></label></td>
         <td  class="idcFieldEntry  idcCheckinUpdateEntry">          <input type="file" name="primaryFile" id="primaryFile-38858" size=35
              
                   maxlength=250 value="">
    </td>
    </tr>
    and - just to compare - a not-required Alternate File
    <tr id="alternateFile-38860_row"
     class="idcRowClass-alternateFile">
         <td class="idcFieldCaption idcCheckinUpdateCaption"><label for="alternateFile-38860">
    Alternate File</label></td>
         <td  class="idcFieldEntry  idcCheckinUpdateEntry">          <input type="file" name="alternateFile" id="alternateFile-38860" size=35
              
                   maxlength=250 value="">
    </td>
    </tr>
    ...and what you want is to toggle between these two.

    I'm not sure is setting the value of required property will do the change, but certainly, you will need a dynamic code that will do something once the value of the field Internal/External changes. Why don't you start from that one? And with hiding (it should be easier)?

    Also, have you considered to have one field, and change its heading?
  • 6. Re: How to set field required on Checkin page depending on another field
    Najdawi Newbie
    Currently Being Moderated
    Thanks so much for your reply,

    about having the same field with changing labels, i cannot do this since the xInternal and xExternal are both option list, and each of them have a different value.

    The good news is:
    the i did the logic that i want; make fields required, in another resource page * <@dynamichtml std_upload_info_script@> *. I did the logic on the Check-In button when it is clicked.

    Thanks again for your help.

    Regards

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points