Solved

How hard to change this formula to JavaScript

Posted on 2004-03-31
13
415 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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
 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

813 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