Skip to main content
edited code
Source Link
Dikesh Gandhi
  • 7.2k
  • 4
  • 31
  • 58

Please try below code:

    var ctx;
     
     SP.SOD.executeFunc('SP'sp.js', 'SP.ClientContext', sharePointReady);
 function sharePointReady () {

                ctx = new SP.ClientContext.get_current();
                var siteColl = ctx.get_site();
                var rootWeb = siteColl.get_rootWeb();
                this.props =  rootWeb.get_allProperties();
                ctx.load(rootWeb);
                ctx.load(this.props); //need to load the properties explicitly
                    
                ctx.executeQueryAsync(Function.createDelegate(this, gotProperty), Function.createDelegate(this, failedGettingProperty));

});
            
            
            function gotProperty() {                
                 var policy = this.props.get_item('GA_PolicyDisplayName');
                 var primarySiteContact = this.props.get_item('GA_PrimarySiteCollectionContact');
                 var secondarySiteContact = this.props.get_item('GA_SecondarySiteCollectionContact');
 
                 elem = document.getElementById('ga-sitecontact');//Pass your desired object
                 elem.innerHTML = "<b>Policy:</b> " + policy  + " <b>Primary Contact:</b> " + primarySiteContact  + " <b>Secondary Contact:</b> " + secondarySiteContact;
            }
            
            function failedGettingProperty() {
                // swallow
            }

Reference:

Hope this will help you.

Please try below code:

    var ctx;
     
     SP.SOD.executeFunc('SP.js', 'SP.ClientContext', function() {

                ctx = new SP.ClientContext.get_current();
                var siteColl = ctx.get_site();
                var rootWeb = siteColl.get_rootWeb();
                this.props =  rootWeb.get_allProperties();
                ctx.load(rootWeb);
                ctx.load(this.props); //need to load the properties explicitly
                    
                ctx.executeQueryAsync(Function.createDelegate(this, gotProperty), Function.createDelegate(this, failedGettingProperty));

});
            
            
            function gotProperty() {                
                 var policy = this.props.get_item('GA_PolicyDisplayName');
                 var primarySiteContact = this.props.get_item('GA_PrimarySiteCollectionContact');
                 var secondarySiteContact = this.props.get_item('GA_SecondarySiteCollectionContact');
 
                 elem = document.getElementById('ga-sitecontact');//Pass your desired object
                 elem.innerHTML = "<b>Policy:</b> " + policy  + " <b>Primary Contact:</b> " + primarySiteContact  + " <b>Secondary Contact:</b> " + secondarySiteContact;
            }
            
            function failedGettingProperty() {
                // swallow
            }

Reference:

Hope this will help you.

Please try below code:

var ctx;
 
 SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady);
 function sharePointReady () {

                ctx = new SP.ClientContext.get_current();
                var siteColl = ctx.get_site();
                var rootWeb = siteColl.get_rootWeb();
                this.props =  rootWeb.get_allProperties();
                ctx.load(rootWeb);
                ctx.load(this.props); //need to load the properties explicitly
                    
                ctx.executeQueryAsync(Function.createDelegate(this, gotProperty), Function.createDelegate(this, failedGettingProperty));

}
            
            
            function gotProperty() {                
                 var policy = this.props.get_item('GA_PolicyDisplayName');
                 var primarySiteContact = this.props.get_item('GA_PrimarySiteCollectionContact');
                 var secondarySiteContact = this.props.get_item('GA_SecondarySiteCollectionContact');
 
                 elem = document.getElementById('ga-sitecontact');//Pass your desired object
                 elem.innerHTML = "<b>Policy:</b> " + policy  + " <b>Primary Contact:</b> " + primarySiteContact  + " <b>Secondary Contact:</b> " + secondarySiteContact;
            }
            
            function failedGettingProperty() {
                // swallow
            }

Reference:

Hope this will help you.

edited code
Source Link
Dikesh Gandhi
  • 7.2k
  • 4
  • 31
  • 58

Please try below code:

_spBodyOnLoadFunctionNames.push("SetGASiteContact");
            function SetGASiteContact()var {ctx;
            
     ExecuteOrDelayUntilScriptLoadedSP.SOD.executeFunc(SetGASiteContactInner'SP.js', "sp'SP.js");
            }
           ClientContext', function SetGASiteContactInner() { 

                var ctx = new SP.ClientContext.get_current();
                var siteColl = ctx.get_site();
                var rootWeb = siteColl.get_rootWeb();
                this.props =  rootWeb.get_allProperties();
                ctx.load(rootWeb);
                ctx.load(this.props); //need to load the properties explicitly
                    
                ctx.executeQueryAsync(Function.createDelegate(this, gotProperty), Function.createDelegate(this, failedGettingProperty));

});
            }
            
            function gotProperty() {                
                 var policy = this.props.get_item('GA_PolicyDisplayName');
                 var primarySiteContact = this.props.get_item('GA_PrimarySiteCollectionContact');
                 var secondarySiteContact = this.props.get_item('GA_SecondarySiteCollectionContact');
 
                 elem = document.getElementById('ga-sitecontact');//Pass your desired object
                 elem.innerHTML = "<b>Policy:</b> " + policy  + " <b>Primary Contact:</b> " + primarySiteContact  + " <b>Secondary Contact:</b> " + secondarySiteContact;
            }
            
            function failedGettingProperty() {
                // swallow
            }

Reference:

Hope this will help you.

Please try below code:

_spBodyOnLoadFunctionNames.push("SetGASiteContact");
            function SetGASiteContact() {
                ExecuteOrDelayUntilScriptLoaded(SetGASiteContactInner, "sp.js");
            }
            function SetGASiteContactInner() {
                var ctx = new SP.ClientContext.get_current();
                var siteColl = ctx.get_site();
                var rootWeb = siteColl.get_rootWeb();
                this.props =  rootWeb.get_allProperties();
                ctx.load(rootWeb);
                ctx.load(this.props); //need to load the properties explicitly
                    
                ctx.executeQueryAsync(Function.createDelegate(this, gotProperty), Function.createDelegate(this, failedGettingProperty));
            }
            
            function gotProperty() {                
                 var policy = this.props.get_item('GA_PolicyDisplayName');
                 var primarySiteContact = this.props.get_item('GA_PrimarySiteCollectionContact');
                 var secondarySiteContact = this.props.get_item('GA_SecondarySiteCollectionContact');
 
                 elem = document.getElementById('ga-sitecontact');//Pass your desired object
                 elem.innerHTML = "<b>Policy:</b> " + policy  + " <b>Primary Contact:</b> " + primarySiteContact  + " <b>Secondary Contact:</b> " + secondarySiteContact;
            }
            
            function failedGettingProperty() {
                // swallow
            }

Reference:

Hope this will help you.

Please try below code:

    var ctx;
      
     SP.SOD.executeFunc('SP.js', 'SP.ClientContext', function() { 

                ctx = new SP.ClientContext.get_current();
                var siteColl = ctx.get_site();
                var rootWeb = siteColl.get_rootWeb();
                this.props =  rootWeb.get_allProperties();
                ctx.load(rootWeb);
                ctx.load(this.props); //need to load the properties explicitly
                    
                ctx.executeQueryAsync(Function.createDelegate(this, gotProperty), Function.createDelegate(this, failedGettingProperty));

});
            
            
            function gotProperty() {                
                 var policy = this.props.get_item('GA_PolicyDisplayName');
                 var primarySiteContact = this.props.get_item('GA_PrimarySiteCollectionContact');
                 var secondarySiteContact = this.props.get_item('GA_SecondarySiteCollectionContact');
 
                 elem = document.getElementById('ga-sitecontact');//Pass your desired object
                 elem.innerHTML = "<b>Policy:</b> " + policy  + " <b>Primary Contact:</b> " + primarySiteContact  + " <b>Secondary Contact:</b> " + secondarySiteContact;
            }
            
            function failedGettingProperty() {
                // swallow
            }

Reference:

Hope this will help you.

Source Link
Dikesh Gandhi
  • 7.2k
  • 4
  • 31
  • 58

Please try below code:

_spBodyOnLoadFunctionNames.push("SetGASiteContact");
            function SetGASiteContact() {
                ExecuteOrDelayUntilScriptLoaded(SetGASiteContactInner, "sp.js");
            }
            function SetGASiteContactInner() {
                var ctx = new SP.ClientContext.get_current();
                var siteColl = ctx.get_site();
                var rootWeb = siteColl.get_rootWeb();
                this.props =  rootWeb.get_allProperties();
                ctx.load(rootWeb);
                ctx.load(this.props); //need to load the properties explicitly
                    
                ctx.executeQueryAsync(Function.createDelegate(this, gotProperty), Function.createDelegate(this, failedGettingProperty));
            }
            
            function gotProperty() {                
                 var policy = this.props.get_item('GA_PolicyDisplayName');
                 var primarySiteContact = this.props.get_item('GA_PrimarySiteCollectionContact');
                 var secondarySiteContact = this.props.get_item('GA_SecondarySiteCollectionContact');
 
                 elem = document.getElementById('ga-sitecontact');//Pass your desired object
                 elem.innerHTML = "<b>Policy:</b> " + policy  + " <b>Primary Contact:</b> " + primarySiteContact  + " <b>Secondary Contact:</b> " + secondarySiteContact;
            }
            
            function failedGettingProperty() {
                // swallow
            }

Reference:

Hope this will help you.