I have some questions :
Is is possible to show a warning message while saving a record(in create) method like record saved successfully.
2.I want to show a warning message while nevigating from the page after clicking create and leaving page without save by clicking on some menu item ,backspace or back button of browser?
I can't understand why you want to show a warning message on save when everything is goes fine.
Warning message is shown when something goes wrong or user break a rule eg. when user don't have a right to create a record of particular object and user try to create a record.
IMHO It is better to use a workflow to define the flow of process like we have a two state new and done default state is new when user create and enter all required field and click on save trigger a workflow and change state from new to done. That tell user that he complete the flow like wise you can put a state as you required.
for more detail on workflow please read from
http://doc.openerp.com/v6.0/developer/3_9_Workflow_Business_Process/index.html
2.I think this feature is already implemented in new upcoming version 7.0.
strong textHi Yes sure you can raise Alert Message when saving record through JS script it is possible you have to write single line code in path addons/web/static/src/js/viewform.js
on_button_save: function() {
var self = this;
return this.save().done(function(result){
**if (!confirm(_t("The record has been saved"))) {
return false;
}**
self.trigger("save", result);
self.reload().then(function() {
self.to_view_mode();
var parent = self.ViewManager.ActionManager.getParent();
if(parent){
parent.menu.do_reload_needaction();
}
});
});
},
Related
I am trying to create an automation script (action launch point, trigger by a button on UI) for Maximo using javascript to do some data validation then show popup if there is invalid data.
I try to call service.setWarning() but the script still process instead of showing a warning message, if I do some UI interaction later, that warning message randomly display later.
Then I try the service.error() which should show an error message similar to the exception message in Maximo, the script does stop running but there is no popup message.
If I check systemError.log, I can see both the warning and error message displayed in the log?
So what is causing this and how can I make it behave correctly?
EDIT1: here is the script, I already setup the message in database configuration (messagegroup RFQ, messagekey 2VENDORS):
load("nashorn:mozilla_compat.js");
importPackage(Packages.psdi.security);
importPackage(Packages.psdi.mbo);
importPackage(Packages.psdi.server);
var mxServer = MXServer.getMXServer();
var userInfo = mxServer.getSystemUserInfo();
var rfqLineSet = mbo.getMboSet("RFQLINE");
var totalCost = 0;
var current_datetime = new Date();
var today = current_datetime.toISOString();
for(var currMbo=rfqLineSet.moveFirst(); currMbo!=null; currMbo=rfqLineSet.moveNext()) {
totalCost = totalCost + currMbo.getDouble("LINECOST");
}
if (totalCost < 50000) {
var rfqVendorSet = mbo.getMboSet("RFQVENDOR");
if (rfqVendorSet.count() > 2) {
service.error("RFQ","2VENDORS",null);
}
}
Maximo version 7.6.1
EDIT2: I tried the service.yncerror("RFQ","2VENDORS",null); which should display a yes/no error popup message but same issue, it only appears in the systemError.log
EDIT3: I did some tests and found out that if I write the code in Jython then the popup works but not in Javascript. How can this be?
UPDATE: I moved all my scripts to use python instead of javascript, seems that Maximo works best with automation script written in python.
Thanks.
"Warnings" in Maximo are some bits of data that just ride along with the MBO set. As a warning, they aren't supposed to stop execution, just let you know of something important, but they won't even do that on their own. You need to do something at some point to fetch the warnings from the set and display them. If you don't, Maximo will on its own for certain actions (usually for those actions that would include a warning Maximo itself added), but that probably isn't when you actually want it to be displayed. I have seen many people mix this up and not understand what these warnings are or how they actually work.
"Errors" are meant to be logic stopping messages. Something went wrong and the user needs to know about it before more logic runs. This sounds more like your use case. Errors are still meant to be a message to the user though, so you have to supply a message for the error method. You can't just put any string you want as your message in there though (well, you shouldn't) as that doesn't allow Maximo to translate the message or fill in message variables. It also means you have to change code whenever you want to change the message, instead of simply changing a configuration live. Instead you need to go to Database Configuration and add a new message in there. When you do that, you will create a message group and message key value for your message. Now when you call the error method, you will pass in that error group and error key as parameters. Maximo will take that, look it up in the message table and then display the message associated with that group and key for your configured language. It can also replace some special message variables at this time too, but that's a lesson for another time.
For example, you might go to Database Configuration and open the dialog for the messages and add a message of "The value you entered in the 'count' field is not a number. Please enter a number before continuing." and give it a message group of "MyCustomGrp" and a key of "NotANumber". Then in your code when you want to stop the code and display that message, you would call service.error("MyCustomGrp", "NotANumber").
The other potential problem you could be having is that you do need to be running the code that throws the error in some way attached to the interactive user session. Generally, that's a given, but there are some things you could be doing that would cause your code to run separate from that interactive user session. If you are seeing your error message in the logs, then you have set that part up correctly and it likely means your code is not part of the interactive user session. This is where knowing the rest of your code is very important.
I'm facing a problem on the Save event of the Quick Create form for the Case entity. On Save event, I'm not able to get the record GUID in JavaScript code.
Our requirement is when the user clicks on Save button on Quick Create form of the Case, we would like to redirect the user to the newly created case record.
We have attached below Javascript function on save event of Quick Create form. This code works well on one of the 30-days trial instance, but it doesn't work well on the client development CRM instance.
setTimeout(function () {
var formContext = executionContext.getFormContext();
var caseId = formContext.data.entity.getId();
caseId = caseId.replace("{", "").replace("}", "");
var entityFormOptions = {};
entityFormOptions["entityName"] = "incident";
entityFormOptions["entityId"] = caseId;
Xrm.Navigation.openForm(entityFormOptions).then(
function (success) {
console.log(success);
},
function (error) {
console.log(error);
});
}, 1000);
Quick create form purpose is flyout data entry without going away from current form/record. The same QC form is being opened from different places like Dashboard, Subgrid, Main navigation too bar, Lookup, etc. and allow user to continue the ongoing stuff. Out of all these places - only from the Main navigation, after the save - system will prompt with a toast to navigate to that record or option to create another record. This is by design.
If you want to navigate to that record irrespective of the origin, you can try some scripts like yours but you are going to break the OOB pipeline flow. You may do some unsupported but it’s not recommended. I never tried it but you can add a function from onSave event, using eventArgs.preventDefault we can stop the OOB save, then open the Full Main form by prepopulating values from QC to Main form, then save it on form load.
Instead of all this pain, why not you open the Main form itself. :)
I'm having nightmares on how to display on the UI what I have changed in my database. I have this scenario that I need to select certain titles and then I will click a button that will change its status.
Problem is when I select titles and then I click the change status button it don't automatically reflect on the UI. Here is my update function.
$scope.updateTitleStatus = function(statusId, cp){
ContentAssessmentService.updateSelectedTitles($scope.selectedTitles, statusId);
$scope.selAll = !$scope.selAll;
$scope.selectedTitles = [];
};
Here is my service.
this.updateSelectedTitles = function(selectedTitle, statusId){
var self = this;
_.forEach(selectedTitle, function(selectedTitle){
ContentAssessmentFactory.updateSelectedTitleStatus(selectedTitle.id, statusId);
});
};
Here is my array which is the selected title stored.
$scope.selectedTitles = [];
Can you tell me how to use $watch function? I don't know how to do it. I've done this but it doesn't work.
$scope.$watch(function($scope){
return $scope.selectedTitles;
}, function(newValue) {
$scope.selectedTitles = newValue;
console.log(newValue);
});
I just need to update the UI immediately without refreshing the page (that's my last option but trying not to) when I have click the change status button.
You are going to have to use polling or a websocket connection. $watch does not "watch" your database. It watches #scope variables that are usually bound to the view and reacts to changes there. It sounds like you are looking for something more like meteor.js that keeps an open websocket and will dynamically update the view when the database is changed from another client, background process etc. These are completely different things. To achieve this sort of behavior with angular, the easiest approach would be to poll your api incrementally and update models in angular when the api gives you modified data.
I am using ServiceNow platform.
I have a requirement in email notification to show the latest work notes ONLY if the work notes have been updated.
Is it possible to query the events queue directly in the email notification and use that event to evaluate an if statement?
The mail script I have right now will display the latest work notes if there are work notes at all, but we just want display it when the work notes were updated only.
The notification is being triggered on the condition that either the additional comments were updated or the assignment group or assigned to changes. So I can't use a simple condition builder.
I also considered the technique in this post but I'm wondering if there is a better way to do this in 2015, this post was back in 2011.
http://www.servicenowguru.com/scripting/business-rules-scripting/checking-modified-fields-script/
<mail_script>
var worknotes = current.work_notes.getJournalEntry(1);
if (worknotes !='') {
template.print("Latest Work Notes:");
template.print(current.work_notes.getJournalEntry(1));
}
</mail_script>
I get the feeling I might not understand the requirement completely, but it seems to me that you could just create a notification that triggers on the condition that the work notes are updated. Wouldn't that be sufficient?
I solved the issue by creating a separate notification and using the advanced condition.
If the comments changes and work notes does not change the notification is sent. I created a separate notification with the same logic, except if the work notes changes and if the comments does not change then that one is sent.
The content of the email are set accordingly so we only see the latest change when it is updated as necessary.
var worknotesChanges = current.work_notes.changes();
if (worknotesChanges) {
answer = false;
}
else {
answer = true;
}
I have an assignment to do and I am a bit confused with saving information and retrieving it.
A few different things:
I have a few textfields(Name, location, age) and I want to be able to save the information written and retreview it once the app is run again.
I want the app to remember what was the last screen run.
How to set a "first time app launch" ex. first time app is launch a profile option is given where then the 2nd time it would skip right away to the main screen because the information has already been provided.
Appreciate your help so much, thanks.
EDIT: Forgot to add the code, although I don't think its important. Because I think my questions are relative to the window names (profileWin, settingsWin, and catWin) and txtfields like firstNameTXF, ageTXF.
I tried using Titanium.App.Properties.setString("firstName", firstNameTXF.value) , which should save the data, but where? And then recalling it using firstNameTXF.value = Titanium.App.Properties.getString("firstName", 1);
1.To save and retrieve values (if only 3 values) use Properties. To Know more about Properties here are the docs.
2.To know which is the last opened window visit this Answer.
3.To check if its first time app launch do something like this :
if(Ti.App.Properties.hasProperty('firsttime')){
//Code for second and subsequent launch
}else{
//first launch
//add your code for first launch
//finally
Ti.App.Properties.setString("firsttime", "true");
}