
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2021 06:45 PM
Hello,
I am trying to make a "spModal" window appear when entering the portal, this window should be shown only if the user has pending surveys and when clicking the "Ir a encuesta" button, it directs me to the page "my_surveys", please one suggestion.
This is my code,
HTML:
<div>
<button class="btn btn-primary" ng-click="c.openModal()">${Open Modal}</button>
</div>
<script type="text/ng-template" id="modalTemplate">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">Modal Window</h4>
</div>
<div class="panel-body wrapper-xl">
Tiene encuestas pendientes!!
</div>
<div class="panel-footer text-right">
<button class="btn btn-primary" ng-click="c.closeModal()">${Recordar mas tarde}</button>
<button class="btn btn-primary" ng-click="c.closeModal()">${Ir a encuesta}</button>
</div>
</div>
</script>
CLIENT SCRIPT:
function($uibModal, $scope) {
var c = this;
c.openModal = function() {
c.modalInstance = $uibModal.open({
templateUrl: 'modalTemplate',
scope: $scope
});
}
c.closeModal = function() {
c.modalInstance.close();
}
}
Solved! Go to Solution.
- Labels:
-
Facilities Service Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2021 07:57 PM
Hey Aurelio, sorry about the delay. The server side script would look something like this.
I tested this in my personal instance and it works.
(function() {
var loggedInUser = gs.getUserID();
data.check = checkForSurvey(loggedInUser);
})();
function checkForSurvey(user){
var gr = new GlideRecord('asmt_assessment_instance');
gr.addQuery("metric_type.active", true);
gr.addQuery("metric_type.publish_state", "published");
gr.addQuery("preview", false);
gr.addQuery('user', user);
var sub = gr.addQuery('state', 'ready');
sub.addOrCondition('state','wip');
gr.query();
if(gr.next())
return true;
else
return false;
}
Then your next step would be to add an 'IF' statement in your client script. something like
if(c.data.check == true){
do the popup
}
else
do nothing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2021 07:22 PM
Where you able to get the pop up to work? looks like it is working on your screen shot. are you needing help adjusting the filter so it only shows with users with an outstanding survey? or are you needing help with the re-direct to the survey page?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2021 06:30 AM
Hi lgomez,
What I need is that this pop-up window is shown when entering the portal as long as the user has pending surveys, as well as the attached image.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2021 12:19 PM
I would recommend doing a query on the server side of the widget to check if there is an active survey. if so, then you can set something like data.survey = true on the server side.
Then on the client side before you initiate the popup add an IF statement something like c.data.survey == true. so if its true then it will popup. ELSE do nothing.
Do you need some help writing the server side query?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2021 03:03 PM
If you please help me with the server side script.