$().SPServices.SPDisplayRelatedInfo to get info to use it in calculated field

Feb 11, 2015 at 9:34 AM
The problem is iam using the SPcascadedropdown in Page layout HTML table.
 <script language="javascript" type="text/javascript" src="/sites/hyd/invoice/SiteAssets/jquery.SPServices-2014.02.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$().SPServices.SPCascadeDropdowns({
    relationshipList: "{15CF0780-F640-47B1-B06E-56E5042F74E0}",
    relationshipListParentColumn: "AccountingUnit",
    relationshipListChildColumn: "SupplierID",
    parentColumn: "Buchungskreis",
    childColumn: "Kreditor",
    debug: false
  });
  $().SPServices.SPCascadeDropdowns({
    relationshipList: "{ECDA6539-EA54-49AA-9DD3-7AF86448EDD0}",
    relationshipListParentColumn: "TermsOfPaymentSupplierID",
    relationshipListChildColumn: "TermsOfPaymentName",
    parentColumn: "Kreditor",
    childColumn: "zahlungskonditionen",
    debug: false
  });
  $().SPServices.SPDisplayRelatedInfo({
    columnName: "zahlungskonditionen",
    relatedList: "{ECDA6539-EA54-49AA-9DD3-7AF86448EDD0}",
    relatedListColumn: "TermsOfPaymentName",
    relatedColumns:["DaysForDiscountFirst"],
    displayFormat: "List",
    debug: true
  });
});
</script>
</asp:Content>
The cascadedropdown is working fine. I have problem in getting related info.

Instead of displaying as a list can get the value and put in a column. Thank you.
Feb 11, 2015 at 10:04 AM
Sorry i saw the Documentation and in the Note its clearly written it can only be used in Newform or editform. So i think in page layout i might not work.
Feb 11, 2015 at 10:38 AM
I changed the displayFormat: "table". Now its getting the value from the DaysForDiscountFirst column. There is one more problem. I right clicked the Page layout --> view source and searched for the DIV with "SPDisplayRelatedInfo_" + columnStaticName it is not there ?.. I want to preprocess the result and save in a column :(..
Coordinator
Feb 11, 2015 at 1:58 PM
When you View Source, you're looking at the page as it was downloaded from the server. That's pretty worthless in this age of JavaScript and client side development. The page continually changes throughout its life cycle.

Instead, you'll want to use one of the developer toolbars - depending on which browser you are using - to look at the live DOM. In most browsers, hitting F12 brings up those tools.

M.
Feb 11, 2015 at 3:42 PM
Edited Feb 11, 2015 at 3:46 PM
Hi Marc,

I tried like this just to see whether the field is there but nothing comes in Alert.
$().SPServices.SPDisplayRelatedInfo({
columnName: "zahlungskonditionen",
relatedList: "{ECDA6539-EA54-49AA-9DD3-7AF86448EDD0}",
relatedListColumn: "TermsOfPaymentName",
relatedColumns:["DaysForDiscountFirst"],
displayFormat: "list",
completefunc:GetRelatedValue(),
debug: true
});

function GetRelatedValue(){
var info = document.getElementsByName("SPDisplayRelatedInfo_DaysForDiscountFirst");
alert(info);
};
Coordinator
Feb 11, 2015 at 3:57 PM
I really think you should inspect the DOM to see what the actual container ID is.

M.
Feb 11, 2015 at 4:23 PM
I inspected the DOM and its Says

<div id="SPDisplayRelatedInfo_undefined">
Coordinator
Feb 11, 2015 at 4:26 PM
Edited Feb 11, 2015 at 4:28 PM
Hmm. Looks like I have a bug in SPServices then. If you're only using SPDisplayRelatedInfo once in the form, you could use this selector:
$("div[id^='SPDisplayRelatedInfo']")
The "'" string should be a single quote: '

What version of SharePoint are you on? What version of jQuery and SPServices are you using?

M.
Feb 11, 2015 at 4:32 PM
Iam using SharePoint 2010. Iam using Jquery 1.11.1 and SPservices.2014.02
Feb 12, 2015 at 11:25 AM
HI Marc,

If i use $("div[id^='SPDisplayRelatedInfo']") it not working..

I got the value like this

var srcDivId = "SPDisplayRelatedInfo_undefined";
        var tds = document.getElementById(srcDivId).getElementsByTagName("td");
if(tds.length>0)
        {
         var discount = tds[0].innerHTML;
          $('ctl00_PlaceHolderMain_Ctrl_DaysforDiscountfirst_ctl00_TextField')[0].Value = discount;
}

This is working but if i have more than one displayrelatedInfo i dont know how it will work ?..

Is this a bug in SPServices?.
Coordinator
Feb 12, 2015 at 2:24 PM
Yes, as I mentioned above, it's a bug. the "undefined" part of the id is obviously not right.

If you do have more than one SPDisplayRelatedInfo we can sort that out in the near term. I'm just trying to get you up and running and then maybe you could help me debug the issue with SPDisplayRelatedInfo?

The selector I gave you should have worked, and I'm not sure why it didn't. But if you've got it working, then hopefully you're good for now.

You're using jQuery.1.11.1 and SPServices 2014.02 on SharePoint 2010. Do you see any script errors when you load the page with the call to SPDisplayRelatedInfo?

M.
Mar 10, 2015 at 1:56 PM
Hi Marc,

Do you recommend something how to access the related info because the selector is not working. jQuery.1.11.1 and SPServices 2014.02 i dont get any script error.
Coordinator
Mar 10, 2015 at 8:28 PM
It's been a while. What are you trying to do at this point? The selector:
$("#SPDisplayRelatedInfo_undefined") 
ought to work, as I mentioned above, but if you have more than one SPDisplayRelatedInfo call, you'll need to be more specific to ensure you're getting the right data.

M.