Solved

How hard to change this formula to JavaScript

Posted on 2004-03-31
13
411 Views
Last Modified: 2013-12-18
This is a action button on my client - but of course the web side can't use it.  Can someone help me translate it to JavaScript?

count_comment_1 := @Prompt([OKCANCELEDIT]; "Counter Propose"; "Please Enter Counter Propose"; " ");
count_comment_2 := "Counter Propose: " + count_comment_1 + @NewLine + @Name([CN]; @UserName) + " " + @Text(@Now);
@SetField("GMMCom"; count_comment_2);

FIELD CMMDate := CMMDate;
@SetField("GMMDate"; @Now);
FIELD CMMStatus := CMMStatus;
@SetField("GMMStatus"; "Counter Proposed");
@Command([RefreshHideFormulas] );

@SetField( "ECRFlowState_2"; "Dell Counter Proposed");
@SetField( "Requester_Name_2"; @Name([CN]; @UserName));
@SetField("Request_Date_2"; @Text(@Today));

ecr_flow_state := ECRFlowState + @NewLine + @Text("Dell Counter Proposed");
@If(ECRFlowState != ""; @Do(@SetField("ECRFlowState_2"; ecr_flow_state); @SetField("ECRFlowState"; "")); "");
@SetField( "ECRFlowState_3"; "Submitted");
ecr_requester_name := Requester_Name + @NewLine + @Name([CN];@UserName);
@If(Requester_Name != ""; @Do(@SetField("Requester_Name_2"; ecr_requester_name); @SetField("Requester_Name"; "")); "");
@SetField( "Requester_Name_3"; @Name([CN]; @UserName));

ecr_status_date :=  Request_date+ @NewLine + @Text(@Now);
@If(Request_Date != ""; @Do(@SetField("Request_Date_2"; ecr_status_date); @SetField("Request_Date"; "")); "");
@SetField("Request_Date_3"; @Text(@Now));
ext_mail := @Trim(DellProEmail);
int_mail := @Trim(ECRRequester_d:LexProEmail);
subject := "Change Request # " + LexECRNum + "Project-" + Project + "   Request Topic-" + ECRSubject + " Has Been Counter Proposed.";
message := "The requested Change Request # " + LexECRNum + "has been Counter Proposed by " + CMMName + @NewLine + count_comment_2 + @NewLine + "Please click the link below to view the Change Request";

@MailSend(int_mail; ""; "";subject; ""; message + @NewLine+@NewLine; [IncludeDoclink]);
@PostedCommand([FileSave]);
@Command([FileCloseWindow])
0
Comment
Question by:Jaziar
  • 5
  • 4
  • 4
13 Comments
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10723941
You cannot convert the above formula as it is in JS.. There is no MailSend capability in JS code.. It it controlled by form header action.

So you have to redefine the functionality seperately for JS.

Seeing the  above code at a glance I feel there is nothing that will work in web except for @Prompt.. There is an equivalent function in JS called prompt. But I will propose you to create a blank field to accept the input on the form and place rest of the code in the button beside it and additionally place a check that the field is not null before you proceed in your code.

~Hemanth
0
 

Author Comment

by:Jaziar
ID: 10724139
So I would need two buttons - one would get the input from the web and after the field is not null a second button could appear to mail the comment?  Does that sound correct?
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10724596
Yes you can
0
 
LVL 14

Expert Comment

by:p_partha
ID: 10725579
What you can ideally do is to do all the validations in the javascript and call the submit actino, In the webquerysave you can call an agent to send a mail

Hope i am clear

Let me know i can try changing the code and give it to you

Partha
0
 

Author Comment

by:Jaziar
ID: 10726869
Where am I going wrong

cw=window.open('','','height=150,width=300,status');
cw.moveTo(200,200);
cw.document.write('<html><head><title>Add Counter Comment</title></head>'+
'<body><form><h3>Please Enter Reason For Counter</h3>'+
'<textarea name=counterText rows=2 cols=30></textarea>'+
'<input type=button value=OK '+
'onClick="document.forms[0].CommentField.value;'+
'opener.document.forms[0].RefreshButton.onclick();window.close()">'+
'<input type=button value=Cancel '+
'onClick="window.close()">'+
'</form></body></html>');
cw.document.close();

Trying to get the typed in user value and assign it to the value counterText and then update the field CommentField on the form
0
 
LVL 14

Expert Comment

by:p_partha
ID: 10726959
Jaziar
there are some issues with it,

ur double quotes are place after onclick = , so it will treat that as a string


tell us exactly what u want to do

Partha

0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:Jaziar
ID: 10727025
I want to have a dialog box to pop up where the user can add a comment - the comment value (text String) will then be placed in a field on the form named CommentField.  Then Refresh the form to show the value.  Everything works except placing the value in the field.
0
 
LVL 14

Expert Comment

by:p_partha
ID: 10727081
something liek this:


cw=window.open('','','height=150,width=300,status');
cw.moveTo(200,200);
cw.document.write('<html><head><title>Add Counter Comment</title></head>'+
'<body><form><h3>Please Enter Reason For Counter</h3>'+
'<textarea name=counterText rows=2 cols=30></textarea>'+
'<input type=button value=OK '+
'onClick="opener.document.forms[0].CommentField.value =document.forms[0].counterText.value"'+
'opener.document.forms[0].RefreshButton.onclick();window.close()">'+
'<input type=button value=Cancel '+
'onClick="window.close()">'+
'</form></body></html>');
cw.document.close();
0
 

Author Comment

by:Jaziar
ID: 10727150
That works and the form refreshes witht the value but the window don't close.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10727160
use cw.close instead of cw.document.close();
0
 
LVL 14

Accepted Solution

by:
p_partha earned 500 total points
ID: 10727193
cw=window.open('','','height=150,width=300,status');
cw.moveTo(200,200);
cw.document.write('<html><head><title>Add Counter Comment</title></head>'+
'<body><form><h3>Please Enter Reason For Counter</h3>'+
'<textarea name=counterText rows=2 cols=30></textarea>'+
'<input type=button value=OK '+
'onClick="opener.document.forms[0].CommentField.value =document.forms[0].counterText.value;opener.document.forms[0].RefreshButton.onclick();self.close()"'+
">"+
'<input type=button value=Cancel '+
'onClick="window.close()">'+
'</form></body></html>');
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10727206
First this not at all needed.. use prompt function like this

document.forms[0].CommentField.value = prompt( "Please Enter reason for counter", "-Enter Comments-");
0
 
LVL 14

Expert Comment

by:p_partha
ID: 10734560
Jaziar
Do you need any more help on this

partha
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now