- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2017 05:41 AM
Can anyone please assist in converting the following into an alert using ${gs.getMessage('message');} so we can display translated values?
I highlighted in red the values I have messages for in the message table to substitute for.
Thanks in advance for the help!!
<script>
function checkMandatorySubmit(rec){
var storeUser = $[jvar_store_user];
if(storeUser)
gsftSubmit(rec);
var manFields = '';
var pcnum = $[jvar_pcnum];
var approver = $[jvar_approver];
var store = $[jvar_store];
var secapprover = $[jvar_approver2];
var location = gel('location').value;
var cube = gel('cube_number').value;
var proj = gel('project').value;
var art = gel('artemis_number').value;
var count = 0;
if(location == ''){
if(count > 0){
manFields += ', Office Location';
}
else{
manFields += 'Office Location';
}
count++;
}
if(pcnum == true){
var pc = gel('pc_tag_num').value;
if(pc == ''){
if(count > 0){
manFields += ', PC Tag #';
}
else{
manFields += 'PC Tag #';
}
count++;
}
}
if(approver == true){
var app = gel('approver').value;
if(app == ''){
if(count > 0){
manFields += ', Approver';
}
else{
manFields += 'Approver';
}
count++;
}
}
if(store == true){
var str = gel('store').value;
if(str == ''){
if(count > 0){
manFields += ', Store';
}
else{
manFields += 'Store';
}
count++;
}
}
if(secapprover == true){
var app2 = gel('approver2').value;
if(app2 == ''){
if(count > 0){
manFields += ', Second Approver';
}
else{
manFields += 'Second Approver';
}
count++;
}
}
if(proj == 'yes') {
if(art == ''){
if(count > 0){
manFields += ', Artemis #';
}
else{
manFields += 'Artemis #';
}
count++;
}
}
if(manFields == ''){
gsftSubmit(rec);
}
else{
alert('The following fields must be completed: ' + manFields);
return false;
}
}
</script>
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2017 06:09 AM
You have to remember that g:evaluate is done on the server, client scripts are done on the client and the Jelly stuff is all pre-processed first. Declaring a server variable cannot magically be used in a client script.
Try this:
if(art == ''){
if(count > 0){
manFields += ', '+='${artemis}';
}
else{
manFields += ' '+='${artemis}';
}
count++;
}
}
FWIW1: Whenever I see an if/else just to place a comma, my first instinct is to try and push all that information in to an array and then use join() to put the array in to a comma separated string. Far less code and keeping track of count variables to know if a comma is needed.
FWIW2: You might want to have a look at episodes 1-3 on all this stuff.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2017 05:46 AM
You will need to get the output from the gs.getMessage() in a server code block before using it in the client block.
Something like this (note this is untested code)
<g:evaluate var="jvar_message">
gs.getMessage('The following fields must be completed');
</g:evaluate>
In your client script code:
alert('$[jvar_message]' + manFields);
You'll likely want to do something similar to your manFields variables/strings as well before appending them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2017 06:25 AM
Thank you as always Chuck... your patience, willingness to help and altruistic nature for us us 'low coders' is greatly appreciated!
I am definitely closer I think the issue now is placement... i'm getting the message to display but it only shows the untranslated fields and not the message (I'm taking baby steps on this and want to get the message working then I will apply the same to the additional variables.)
<g:evaluate var="ManFieldMsg"> | ||||
gs.getMessage('ManFieldMsg'); | ||||
</g:evaluate> |
<script>
function checkMandatorySubmit(rec){
var storeUser = $[jvar_store_user];
if(storeUser)
gsftSubmit(rec);
var manFields = '';
var pcnum = $[jvar_pcnum];
var approver = $[jvar_approver];
var store = $[jvar_store];
var secapprover = $[jvar_approver2];
var location = gel('location').value;
var cube = gel('cube_number').value;
var proj = gel('project').value;
var art = gel('artemis_number').value;
var count = 0;
if(location == ''){
if(count > 0){
manFields += ', Office Location';
}
else{
manFields += 'Office Location';
}
count++;
}
if(pcnum == true){
var pc = gel('pc_tag_num').value;
if(pc == ''){
if(count > 0){
manFields += ', PC Tag #';
}
else{
manFields += 'PC Tag #';
}
count++;
}
}
if(approver == true){
var app = gel('approver').value;
if(app == ''){
if(count > 0){
manFields += ', Approver';
}
else{
manFields += 'Approver';
}
count++;
}
}
if(store == true){
var str = gel('store').value;
if(str == ''){
if(count > 0){
manFields += ', Store';
}
else{
manFields += 'Store';
}
count++;
}
}
if(secapprover == true){
var app2 = gel('approver2').value;
if(app2 == ''){
if(count > 0){
manFields += ', Second Approver';
}
else{
manFields += 'Second Approver';
}
count++;
}
}
if(proj == 'yes') {
if(art == ''){
if(count > 0){
manFields += ', Artemis #';
}
else{
manFields += 'Artemis #';
}
count++;
}
}
if(manFields == ''){
gsftSubmit(rec);
}
else{
alert('$[ManFieldMsg]' + manFields);
return false;
}
}
</script>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2017 06:40 AM
Hi Robert,
Can you clarify what you mean by this...
it only shows the untranslated fields and not the message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2017 10:00 AM