This project has moved. For the latest updates, please go here.
1

Closed

Title Changed for Required Fields after CU for Sharepoint 2010

description

From https://spservices.codeplex.com/discussions/528533


I just installed the update on our Dev box. Here is what a required select now looks like:
<td width="190px" valign="top" class="ms-formlabel" >
    <H3 class="ms-standardheader">
        <nobr>Guideline<span class="ms-formvalidation"> *</span></nobr></H3>
</td>
<td valign="top" class="ms-formbody" >
    <span dir="none">
        <select name="ctl00$m$g_308135f8_3f59_4d67_b5f8_c26776c498b7$ff51$ctl00$Lookup" id="ctl00_m_g_308135f8_3f59_4d67_b5f8_c26776c498b7_ff51_ctl00_Lookup" title="Guideline Required Field">
        </select>
        <br/>
    </span>
</td>
I have not tested SPServices yet but have ran into issues with other plugins.
Closed Aug 12, 2014 at 3:42 PM by sympmarc
Fixed/added/closed in 2014.01

comments

sympmarc wrote Feb 11, 2014 at 10:13 PM

Added a fix in 2014.01ALPHA4. The fix uses the comments at the top of the td.ms-formbody element to find the select.
            // Simple, filding based on the comment text at the top of the td.ms-formbody where the select's title begins with DisplayName - needed for required columns where title="DisplayName Required Field"
            //   Example: SP2010 <select name="ctl00$m$g_308135f8_3f59_4d67_b5f8_c26776c498b7$ff51$ctl00$Lookup" id="ctl00_m_g_308135f8_3f59_4d67_b5f8_c26776c498b7_ff51_ctl00_Lookup" title="Region Required Field">
        } else if ((columnObj.Obj = findFormField(opt.displayName).find("select[title^='" + opt.displayName + "']")).length === 1) {
            columnObj.Type = dropdownType.simple;

wkmaylish wrote Feb 12, 2014 at 12:11 PM

Here is the markup for a complex dropdown
<tr>
    <td nowrap="true" valign="top" width="190px" class="ms-formlabel">
        <h3 class="ms-standardheader">
            <nobr>Lookup Tasks<span class="ms-formvalidation" title="This is a required field." > *</span></nobr>
        </h3>
    </td>
    <td valign="top" class="ms-formbody">
        <!-- FieldName="Lookup Tasks"
             FieldInternalName="Lookup_x0020_Tasks"
             FieldType="SPFieldLookup"
          -->
        <span dir="none">
            <span style="vertical-align:middle">
                <input name="ctl00$m$g_ef96bb30_22ce_4907_a82c_b5aeb24cd553$ctl00$ctl05$ctl06$ctl00$ctl00$ctl04$ctl00$ctl01" 
                    type="text" id="ctl00_m_g_ef96bb30_22ce_4907_a82c_b5aeb24cd553_ctl00_ctl05_ctl06_ctl00_ctl00_ctl04_ctl00_ctl01" 
                    class="ms-lookuptypeintextbox" 
                    onfocusout="CoreInvoke('HandleLoseFocus')" 
                    opt="_Select" title="Lookup Tasks" 
                    optHid="SPLookup_x0020_Tasks_Hidden" 
                    onkeypress="CoreInvoke('HandleChar')" 
                    onkeydown="CoreInvoke('HandleKey')" 
                    match="" 
                    choices="" 
                    onchange="CoreInvoke('HandleChange')" />
                <img alt="Display lookup values" 
                    onclick="CoreInvoke('ShowDropdown','ctl00_m_g_ef96bb30_22ce_4907_a82c_b5aeb24cd553_ctl00_ctl05_ctl06_ctl00_ctl00_ctl04_ctl00_ctl01');" 
                    src="/_layouts/images/dropdown.gif" 
                    style="border-width:0px;vertical-align:middle;" />
            </span>
            <br/>
        </span>     
    </td>
</tr>

sympmarc wrote Feb 12, 2014 at 1:15 PM

So it looks like the " Required Field" text is not added to the input element here. e.g., title="Lookup Tasks". Good to know.

Does the fix I posted for the simple select work for you?

M.

DeannaS wrote Mar 11, 2014 at 6:49 PM

I'm testing the alpha code and it seems to work for SPFilterDropdown, but not for SPCascadeDropdowns.
//Filter  priorities - this works with the required field Educational Priority
$().SPServices.SPFilterDropdown({
  relationshipWebURL: "/tools/accountability",
  relationshipList: "Educational Priority",
  relationshipListColumn: "Title",
  relationshipListSortColumn: "ID",
  columnName: "Educational Priority",
  CAMLQuery: " <Eq><FieldRef Name='Active' /><Value Type='Integer'>1</Value></Eq>",
  completefunc: removePriorityBlankOption,
  debug: true
});

//End filter priorities

// Cascade the outcomes - This does not work with the required field Educational Priority
$().SPServices.SPCascadeDropdowns({
    relationshipWebURL: "/tools/accountability",
    relationshipList: "Outcome Statement",
    relationshipListParentColumn: "Priority",
    relationshipListChildColumn: "Title",
    CAMLQuery: "<Eq><FieldRef Name='Active' /><Value Type='Integer'>1</Value></Eq>",   
    parentColumn: "Educational Priority",
    childColumn: "Outcome Statement Lookup",
    debug: true,
    completefunc: drawOutcomeStatementCheckboxes
  });
      
// end cascade outcomes

DeannaS wrote Mar 11, 2014 at 6:52 PM

Wait, I may have been wrong. I don't think either are working for me. This is the entire rendered code in IE 10. There are no comments like you'd mentioned above:
<td width="190px" valign="top" class="ms-formlabel"><H3 class="ms-standardheader"><nobr>Educational Priority<span class="ms-formvalidation"> *</span></nobr></H3></td><td width="400px" valign="top" class="ms-formbody"><span dir="none"><select name="ctl00$m$g_16de9b61_74c3_4330_b859_cc7b43a7072b$ff31$ctl00$Lookup" id="ctl00_m_g_16de9b61_74c3_4330_b859_cc7b43a7072b_ff31_ctl00_Lookup" title="Educational Priority Required Field">
                    <option value="4">Food Security and Health</option>
                    <option value="5">My work does not fit into any of the institutional educational priorities.</option>
                    <option value="2">Resilient and Productive Environments</option>
                    <option value="1">Sustainable Economies</option>
                    <option value="3">Thriving Youth, Families and Communities</option>
                    <option value="6">Ths one is not active</option>

                </select><br/></span>Please select the most appropriate educational priority.</td>

MoOnBoY wrote Mar 12, 2014 at 5:01 PM

Its not working for required fields.

My fields are not rendered like you are searching for them. Their ID does not start with the field name.

Sample:
<select name="ctl00$m$g_6da0ab13_471d_47e1_8c9c_81483e315dae$ctl00$ctl05$ctl00$ctl00$ctl00$ctl04$ctl00$Lookup" title="Process Required Field" id="ctl00_m_g_6da0ab13_471d_47e1_8c9c_81483e315dae_ctl00_ctl05_ctl00_ctl00_ctl00_ctl04_ctl00_Lookup">

You have to use the TITLE or search the comment node:
FieldName="Process"
         FieldInternalName="Process"
         FieldType="SPFieldLookup"

mayurnjoshi wrote Mar 26, 2014 at 3:55 PM

Hi Marc,

I ran into issues today to make the simple required dropdown field cascade & was able to narrow down the root cause to the code block Last ditch effort where you are trying to select the dropdown using
   var fieldSelect = fieldContainer.find("select[title^='" + opt.displayName + "'][id$='$Lookup']");
The code fails because the above line of code looks for "$Lookup" in id attribue; whereas it should be looking for "$Lookup" in name attribute... Once I make that change in the non-minified JS, the lookup now works fine.

DeannaS wrote Mar 26, 2014 at 7:41 PM

So, I know you have this marked as resolved, but it doesn't seem to be resolved to me. I did some more digging today. Our test server has the Service Pack 2 update. Your production server does not. Everything works on production. On test, using the latest download (jquery.SPServices-2014.01.js), I'm running the following SpServices calls:
// Ensure that this stays a simple dropdown
$().SPServices.SPComplexToSimpleDropdown({  
    columnName: "Related Grant",
    completefunc: null,
    debug: false
});


//Filter Grants 
$().SPServices.SPFilterDropdown({
      relationshipList: "Report of Grant Funds",
      relationshipListColumn: "Title",
      relationshipListSortColumn: "ID",
      columnName: "Related Grant",
      CAMLQuery: CAMLQuery,
      completefunc: checkGrants,
      debug: true
    });
I've added a bunch of debugging to spServices to see where it's failing. In this function:
$.fn.SPServices.SPDropdownCtl

It's returning columnObj.Type = null;

So, it drops into the last ditch effort, and in there, it can't find the fieldContainer.

I'm using custom forms, so the comment isn't there by default. In order to make it work I have to add:
<xsl:comment> FieldName="Related Grant" FieldInternalName="RelatedGrant" FieldType="SPFieldLookup"</xsl:comment>
This is what renders:
<span dir="none"><select name="ctl00$m$g_9015485b_cdfd_48e1_a53f_0362077c0b09$ff41$ctl00$Lookup" id="ctl00_m_g_9015485b_cdfd_48e1_a53f_0362077c0b09_ff41_ctl00_Lookup" title="Related Grant Required Field">
                    <option value="67">alsjdflj</option>
                    

                </select><br/></span>

sympmarc wrote Mar 31, 2014 at 1:08 PM

For each of you who have posted above, can you please let me know what your version of SharePoint is and what CU you have installed? AFAIK, the " Required Field" issue is occurring in these environments:
  • SharePoint online (Office365) after an update about mid-January
  • SharePoint 2013 on premises when the December 2013 CU and/or SP1 (Feb 2014) has been applied
  • SharePoint 2010 with SP2 applied
    The markup for these fields is different between SharePoint 2010 and 2013, so I need to know what you're seeing and where.
mayurnjoshi may have a useful fix above for SharePoint 2010. Unfortunately, I don't have an environment running SharePoint 2010 with SP2 installed for testing. The fix I put into 2014.01 was blind on my part, but validated by others.

Thanks,
M.

mayurnjoshi wrote Mar 31, 2014 at 5:52 PM

Hi Marc,

Version # for my environment is MicrosoftSharePointTeamServices: 14.0.0.7113... This is SharePoint 2010 Office 365 dedicated.

maunx wrote May 5, 2014 at 9:24 AM

Still not working for me either.

Version: Office 365 (SharePoint 2013)
version no: 16.0.0.2811

billyjimjack wrote May 30, 2014 at 7:13 PM

mayurnjoshi's fix worked for me. Although, I made the change in the minified version as well.

Search for id$='$Lookup' in the minified and full JS files and replace with name$='$Lookup'

sympmarc wrote Jun 2, 2014 at 1:41 PM

This one has been vexing. Things seem to be working fine for some people and not for others, all with the same update level. In order to understand why it is failing n some cases, I really need to see the markup. I don't have all of the different environments that you guys have.

M.