Reopen incident button on portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2023 06:26 AM
Hi,
I have created a reopen incident button on our company portal which prompts users to provide a comment as to why they are reopening it using the below script. However there is an issue whereby when the the button is opened and the comments box is opened it shows text inputted saying [object Object]. Unsure of how to have it so its empty and why this is showing.
Thanks in advance. Script below:
function($scope, $window, spModal) {
var c = this;
c.action = function(state) {
if (c.data.comments == undefined || c.data.comments == '') {
spModal.prompt('Please provide a valid explanation as to why the ticket is being reopened, without this it won\'t be actioned', {
inputConfig: {
minlength: 10, // Minimum character limit for the text box
maxlength: 1000 // Maximum character limit for the text box
}
}).then(function(newComments) {
if (newComments.length >= 10) { // Minimum character limit check
c.data.state = state;
c.data.comments = newComments;
c.server.update();
} else {
spModal.alert("Please enter at least 10 characters.");
}
});
} else {
c.data.state = state;
c.data.action = false;
c.server.update();
}
};
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2023 09:32 AM
Hi @liamregan5 ,
You can update the code to access the actual value of the input field instead of the entire object.
Here's the modified script:
function($scope, $window, spModal) {
var c = this;
c.action = function(state) {
if (c.data.comments == undefined || c.data.comments == '') {
spModal.prompt('Please provide a valid explanation as to why the ticket is being reopened. Without this, it won\'t be actioned.', {
inputConfig: {
minlength: 10, // Minimum character limit for the text box
maxlength: 1000 // Maximum character limit for the text box
}
}).then(function(response) {
var newComments = response.inputValue;
if (newComments.length >= 10) { // Minimum character limit check
c.data.state = state;
c.data.comments = newComments;
c.server.update();
} else {
spModal.alert("Please enter at least 10 characters.");
}
});
} else {
c.data.state = state;
c.data.action = false;
c.server.update();
}
};
}
If my response was helpful in resolving the issue, please consider accepting it as a solution by clicking on the ✅Accept solution button and giving it a thumbs up 👍. This will benefit others who may have a similar question in the future.
Thank you!
Ratnakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2023 12:59 AM
Hi @Ratnakar7 , It seems to provide the same outcome with [object Object] in the text input box