
- 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-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-14-2021 05:29 PM
Thank you very much for your help lgomez, I was finally able to finish the configuration for the popup window.