Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

152
Views
spModal: "shared" option

spModal seems to have an option called "shared" as per here: https://github.com/service-portal/x-archive/blob/master/documentation/spModal.md (scroll down to shared).

I am trying to get this to work.

In our service portal I have a page with a client script that loads a widget, I have added the "shared" option here as per above link:

function onLoad() {
    if (g_scratchpad.canWrite && !g_form.isReadOnly('u_custom_company') && spModal) {

        var wait = setInterval(function() {
            var vendorEle = this.document.querySelector('#u_custom_company > .form-group');
            if (!vendorEle) {
                return;
            }
            
            var ccompany = {};
            
            var btn = this.document.createElement('button');
            btn.innerHTML = 'Add New Custom Company';
            btn.className = 'btn btn-sm btn-primary m-t-sm';
            btn.onclick = function() {
                spModal.open({
                    title: 'Add New Custom Company',
                    widget: 'new_custom_company',
                    footerStyle: { display: "none" },
                    shared: ccompany
                }).then(function() {
                        // Shared object was updated
                        console.log(ccompany);
                    });

            };
            vendorEle.appendChild(btn);

            clearInterval(wait);
        }, 500);
    }
}

In the above script I keep getting "undefined" in the result of the console.log().

Then in the client script of my custom widget I am unsure how to assign a value to this shared variable so that the above client script has access to it. This is what I have tried so far:

function($scope) {
        /* widget controller */
        var c = this;
        c.submit = function() {

            if ( $('#name').val() && ( $('#idone').val() || $('#idtwo').val() )) {
                c.data.action = 'createCustomCompany';
                c.server.update().then(function() {
                                    c.widget.options.shared = $scope.data.custom_companay.sys_id;

                                    });
                            
                // close modal popup when submit is clicked
                $scope.$parent.$parent.buttonClicked({ label: "Submit", submit: true });
            } else {
                $('.errormessage').show();
            }
        };
}

custom_company.sys_id is being populated by my server script and contains a sys_id, for example of a newly created custom company record.

I am unsure how to hand over the data from $scope.data.custom_companay.sys_id to the variable in the first client script?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!