• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 423
  • Last Modified:

How hard to change this formula to JavaScript

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
Jaziar
Asked:
Jaziar
  • 5
  • 4
  • 4
1 Solution
 
HemanthaKumarCommented:
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
 
JaziarAuthor Commented:
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
 
HemanthaKumarCommented:
Yes you can
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
p_parthaCommented:
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
 
JaziarAuthor Commented:
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
 
p_parthaCommented:
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
 
JaziarAuthor Commented:
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
 
p_parthaCommented:
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
 
JaziarAuthor Commented:
That works and the form refreshes witht the value but the window don't close.
0
 
HemanthaKumarCommented:
use cw.close instead of cw.document.close();
0
 
p_parthaCommented:
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
 
HemanthaKumarCommented:
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
 
p_parthaCommented:
Jaziar
Do you need any more help on this

partha
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now