Cascading Dropdown Intermittent Issue: Child field not generated

Apr 4, 2013 at 9:18 AM
I am supporting our company's sharepoint custom code (new team) and am fairly new with regards to jquery. In one of our sites, we use a simple cascading dropdown to generate the list of values of the Resolution Code field depending on the Reason Code field.

The issue is that in the Production environment, users have reported that there are times where in the Resolution Code is not being generated. This happens whenever they are filling up the fields when adding a new item to the Service Requests list.

This is an intermittent issue so they can't repeat it on purpose. Since I cannot test in our Production environment, I tried doing it in Test but could not replicate the issue. I have asked the user to try and reproduce in Test but are unable to do it now because of their workload.

The SPServices version we are using is 0.7.1a.min.js

The SPServices command is called from a custom js file named forms.js "$(document).ready(function()" function

We are accessing from the company Intranet, using the company standard machine where the browser is IE Version 8.0.7601.17514

There are several variables to consider that may attribute to this issue. Would you be able to guide me as to narrowing down and getting to the root cause?

Do you see any compatibility issues with the browser & SPServices version?

Let me know if sending the forms.js file will help

Thanks in advance!
Coordinator
Apr 4, 2013 at 4:33 PM
All sounds normal from this end. Can you show your code and explain a bit more what you mean by "the Resolution Code is not being generated"?

M.
Apr 5, 2013 at 2:43 AM
Thank you for your response. By "Resolution Code is not being generated" I mean that the drop down values do not get populated and therefore, the user has no options to choose. Again, it is only an intermittent issue


Here are the first few lines of forms.js which calls the functions related to the newForm. Its not the whole code so I might be missing some parenthesis when I pasted and deleted some lines here but you will see below the relevant code.



/******************************/
/ GLOBAL /
/******************************/

var isadmin=false;
var iscontributor=false;
var username=$().SPServices.SPGetCurrentUser();

$(document).ready(function(){

// Permissions handling
if($.cookie('c1_username') != username){
// $.cookie('c1_is_admin', null);
}
isadmin=$.cookie('c1_is_admin');
if(!$.cookie('c1_is_admin')){
setUserPerms();
}

if(isPage('DispForm.aspx')){
$('#ctl00_m_g_6fa5b9c4_c769_4474_b0c7_86f47a03c391_ctl00_ctl01_ctl00_toolBarTbl td:eq(7)').hide();
$('#ctl00_m_g_6fa5b9c4_c769_4474_b0c7_86f47a03c391_ctl00_ctl01_ctl00_toolBarTbl td:eq(8)').hide();

}

if(isPage('newServiceRequest')||isPage('servicerequests/newForm.aspx')||isPage('archive/newForm.aspx')){
assignRowAttributes();

// hide the reassign flag since we are going to control it automatically
$('.reassign_request').hide();
$('.reassign_flag').hide();
$('.case_id').hide();
$('.2nd_level_support_returned').hide();

newServiceRequestInit();
}






Here are the functions called when the condition for newForm is met above:


/******************************************************/
/ FIELD MANIPULATION /
/******************************************************/

function assignRowAttributes(){
$('.ms-formlabel').parent().each(function(){
var label=$(this).find('h3 nobr').text();
if(label==''){
$(this).attr('title',label);
}
else{
$(this).attr('rel',label);
}
$(this).addClass(createFieldID(label));
});
}

function createFieldID(title){
var newString = title.replace(/[^a-zA-Z 0-9]+/g,'');
newString=$.trim(newString);
newString=newString.replaceAll(' ','_');
newString=newString.toLowerCase();
return newString;
}

function newServiceRequestInit(){
$().SPServices.SPCascadeDropdowns({
relationshipWebURL: "",
relationshipList: "Resolution codes",
relationshipListParentColumn: "Reason_x0020_Code",
relationshipListChildColumn: "Title",
relationshipListSortColumn: "",
parentColumn: "Reason Code",
childColumn: "Resolution Code",
CAMLQuery: "",
listName: $().SPServices.SPListNameFromUrl(),
promptText: "Choose {0}...",
simpleChild: false, // Added in v0.6.2
selectSingleOption: false, // Added in v0.6.2
matchOnId: false, // Added in v0.7.1 completefunc: null,
debug: true
});

$('input[title="Resolution Code"]').change(function(){
$(".error").hide();
var currentval=$(this).val();
if(currentval=="Other"){
alert('Please describe the resolution method in the Problem Description field');
}
});

$('.closed_flag input').click(function(){
if($(this).attr('checked')){
$('.resolution_code input').attr('required','required');
$('tr.resolution_code nobr').append('<span class="ms-formvalidation"> *</span>');
}
else{
$('.resolution_code input').removeAttr('required');
$('tr.resolution_code nobr span .ms-formvalidation').remove();
}
});
$('select[title=Status]').click(function(){
if($(this).val()=='Closed'){
$('input[title=Resolution Code],select[title=Resolution Code]').attr('required','required');
}
else{
$('input[title=Resolution Code],select[title=Resolution Code]').removeAttr('required');
}
});

}


function isPage(URL){
if(window.location.href.toLowerCase().indexOf(URL.toLowerCase())!=-1){ return true; }
else{ return false; }
}
Coordinator
Apr 5, 2013 at 3:55 AM
A few things:
  • You should only specify the options that you want to set. So, for instance, you don't need to have listName: $().SPServices.SPListNameFromUrl(), because that's the default.
  • If it's intermittent, can you figure out any pattern? If it's only some users, then it's probably a permissions problem. I assume that all users can read from the relationshipLists?
  • If it isn't permissions, then is your call to newServiceRequestInit(); inside the $(document).ready()? I can't tell for sure, but as you say, you may have missed a bracket or parenthesis.
  • Finally, check the results coming back with Firebug or Fiddler to see if you're getting the values back that you expect when you change the parent value. It could be that something about your list structures isn't right (though it looks like it probably is).
M.
Apr 15, 2013 at 6:53 AM
Hello, thanks for your response. There is no pattern and this issue cannot be reproduced on purpose.

The users mentioned they are using multiple tabs at the same time. Does this affect the usability of the cascading dropdown?

I asked for a copy of our logs and I saw errors right about the time the users reported the issue. Seems like timeout errors. Do you think this is related to the issue at hand?

Here's part of the error log. Sorry for the formatting...



04/03/2013 12:32:47.70 w3wp.exe (0x1BD8) 0x0930 SharePoint Foundation Database fa45 High System.Threading.ThreadAbortException: Thread was being aborted. at SNIReadSync(SNI_Conn* , SNI_Packet** , Int32 ) at SNINativeMethodWrapper.SNIReadSync(SafeHandle pConn, IntPtr& packet, Int32 timeout) at System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult asyncResult, TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParserStateObject.ReadNetworkPacket() at System.Data.SqlClient.TdsParserStateObject.ReadBuffer() at System.Data.SqlClient.TdsParserStateObject.ReadByte() at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() at System.Data.SqlClient.S... e89b6c45-a6c6-417e-91bc-c2a1d00f4957
04/03/2013 12:32:47.70* w3wp.exe (0x1BD8) 0x0930 SharePoint Foundation Database fa45 High ...qlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior... e89b6c45-a6c6-417e-91bc-c2a1d00f4957
04/03/2013 12:32:47.70* w3wp.exe (0x1BD8) 0x0930 SharePoint Foundation Database fa45 High ...) at Microsoft.SharePoint.Utilities.SqlSession.ExecuteReader(SqlCommand command, CommandBehavior behavior, SqlQueryData monitoringData, Boolean retryForDeadLock) e89b6c45-a6c6-417e-91bc-c2a1d00f4957
04/03/2013 12:32:47.71 w3wp.exe (0x1BD8) 0x0930 SharePoint Foundation Database fa46 High at Microsoft.SharePoint.SPSqlClient.ExecuteQueryInternal(Boolean retryfordeadlock) at Microsoft.SharePoint.SPSqlClient.ExecuteQuery(Boolean retryfordeadlock) at Microsoft.SharePoint.Library.SPRequestInternalClass.GetListItemDataWithCallback2(IListItemSqlClient pSqlClient, String bstrUrl, String bstrListName, String bstrViewName, String bstrViewXml, SAFEARRAYFLAGS fSafeArrayFlags, ISP2DSafeArrayWriter pSACallback, ISPDataCallback pPagingCallback, ISPDataCallback pPagingPrevCallback, ISPDataCallback pFilterLinkCallback, ISPDataCallback pSchemaCallback, ISPDataCallback pRowCountCallback, Boolean& pbMaximalView) at Microsoft.SharePoint.Library.SPRequest.GetListItemDataWithCallback2(IListItemSqlClient pSqlClient, String bstrUrl, String bstrListName, String bstrViewName, String bs... e89b6c45-a6c6-417e-91bc-c2a1d00f4957
04/03/2013 12:32:47.71* w3wp.exe (0x1BD8) 0x0930 SharePoint Foundation Database fa46 High ...trViewXml, SAFEARRAYFLAGS fSafeArrayFlags, ISP2DSafeArrayWriter pSACallback, ISPDataCallback pPagingCallback, ISPDataCallback pPagingPrevCallback, ISPDataCallback pFilterLinkCallback, ISPDataCallback pSchemaCallback, ISPDataCallback pRowCountCallback, Boolean& pbMaximalView) at Microsoft.SharePoint.SPListItemCollection.EnsureListItemsData() at Microsoft.SharePoint.SPListItemCollection.get_Count() at Microsoft.SharePoint.WebControls.SingleDataSource.GetXPathNavigatorInternal() at Microsoft.SharePoint.WebControls.SingleDataSource.GetXPathNavigator() at Microsoft.SharePoint.WebPartPages.DataFormWebPart.GetXPathNavigator(String viewPath) at Microsoft.SharePoint.WebPartPages.DataFormWebPart.PrepareAndPerformTransform(Boolean bDeferExecuteTransform) at Microsoft.Share... e89b6c45-a6c6-417e-91bc-c2a1d00f4957
04/03/2013 12:32:47.71* w3wp.exe (0x1BD8) 0x0930 SharePoint Foundation Database fa46 High ...Point.WebPartPages.DataFormWebPart.PerformSelect() at Microsoft.SharePoint.WebPartPages.DataFormWebPart.DataBind() at Microsoft.SharePoint.WebPartPages.DataFormWebPart.EnsureDataBound() at Microsoft.SharePoint.WebPartPages.DataFormWebPart.CreateChildControls() at System.Web.UI.Control.EnsureChildControls() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at... e89b6c45-a6c6-417e-91bc-c2a1d00f4957
04/03/2013 12:32:47.71* w3wp.exe (0x1BD8) 0x0930 SharePoint Foundation Database fa46 High ... System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error) at System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb) at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(In... e89b6c45-a6c6-417e-91bc-c2a1d00f4957
04/03/2013 12:32:47.71* w3wp.exe (0x1BD8) 0x0930 SharePoint Foundation Database fa46 High ...tPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags) at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags) at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags) at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags) e89b6c45-a6c6-417e-91bc-c2a1d00f4957
04/03/2013 12:32:47.71 w3wp.exe (0x1BD8) 0x0930 SharePoint Foundation Database tzku High ConnectionString: 'Data Source=USATLBYISQL1\BYIA;Initial Catalog=TSApps_Content_08;Integrated Security=True;Enlist=False;Asynchronous Processing=False;Connect Timeout=15' ConnectionState: Closed ConnectionTimeout: 15 e89b6c45-a6c6-417e-91bc-c2a1d00f4957
04/03/2013 12:32:47.75 w3wp.exe (0x1BD8) 0x0930 SharePoint Foundation Database tzkv High SqlCommand: 'DECLARE @DocParentIdForRF uniqueidentifier SELECT TOP 1 @DocParentIdForRF = Docs.Id FROM Docs WHERE Docs.SiteId = @SITEID AND Docs.DirName = @FDN AND Docs.LeafName = @FLN; SELECT t21., t22.[ntext4], t22.[ntext5], t22.[ntext1], t22.[ntext2], t22.[ntext6], t23.[MetaInfo] AS c41, t22.[ntext3] FROM (SELECT DISTINCT t18.[tp_Ordinal], t3.[tp_ID] AS c18, t19.[nvarchar1] AS c18c19, t20.[nvarchar10] AS c22c23, t17., t6.[tp_ID] AS c22 FROM (SELECT TOP(@NUMROWS) t1.[SortBehavior] AS c0, UserData.[datetime1], UserData.[nvarchar10], t10.[nvarchar1] AS c29c30, UserData.[tp_ItemOrder], t1.[TimeLastModified] AS c15, UserData.[nvarchar1], UserData.[nvarchar23], UserData.[bit2], t15.[nvarchar1] AS c35c7, UserData.[tp_ParentId], UserData.[tp_DocId], t5.[nvarchar4] AS c21c9, t8.[Status1] ... e89b6c45-a6c6-417e-91bc-c2a1d00f4957
04/03/2013 12:32:47.75* w3wp.exe (0x1BD8) 0x0930 SharePoint Foundation Database tzkv
Coordinator
Apr 15, 2013 at 3:17 PM
Sorry, but I don't see anything there that would explain it, either. Having multiple browser windows open shouldn't matter at all. The scripts run in the browser instance and can't interfere with each other.

If you're seeing timeouts in the logs, then it may be something going on with your farm. The Web Services are extremely reliable. Again, I'd suggest watching the Net traffic and seeing if you're getting any errors.

M.
Jul 1, 2013 at 10:21 AM
Hello,

Apologies for not updating and getting back earlier. We found that the site was experiencing some timeouts and during this time the cascading drop downs would not respond as described above.

Thanks for your help
Coordinator
Jul 1, 2013 at 1:29 PM
Glad you figured out the issues. The Web Services will be laggy if your farm is sick, just as page loads will. Overall form health is key!

M.