Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Set Default Value of a Field via the Web and a Formula

Posted on 2005-02-28
14
Medium Priority
?
1,031 Views
Last Modified: 2013-12-18
This is for the web.  I have two fields, one is a combobox with values 1-10 (MyField1) and the other is 100-200 (MyField2).  I have an embedded view that has Show Single Category set to MyField1 + MyField2 via a computed field that gets computed when the combobox's refresh the page.

Basically, the user can pick from the first list and then pick from the second list to form a number.  I need to combine that number into a field, that needs to be hidden.  

I have tried setting the default value of a field by: MyField1 + MyField2 and @SetField("FieldTotal"; MyField1 + MyField2).  I'm sure I am just off.
0
Comment
Question by:DawG25
  • 6
  • 5
  • 3
14 Comments
 

Author Comment

by:DawG25
ID: 13422892
I want to use the combine values of the combobox's as a key in a later to be used @DBLookup
0
 
LVL 13

Expert Comment

by:CRAK
ID: 13423171
Bear in mind that comboboxes are text based, not numeric.
You could set the default value for MyField1 to "1". Just as you would for a notes application.
Similarly set MyField2's default formula to "100".

Now set the hidden field (don't hide it yet for verification!) to computed, text and assign the formula: MyField1 + MyField2.

Easiest now it to set "refresh fields on keyword change" to both of the comboboxes. I'll cause a reload and even in the browser recompute the "hidden" field.
0
 

Author Comment

by:DawG25
ID: 13423190
That part works great.  How can I access the computed field though in my @DBLookup or put it into another FIELD.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:DawG25
ID: 13423233
The other field is just text editable, not computted.
0
 

Author Comment

by:DawG25
ID: 13423544
I basically am combining the two combobox values to attempt to get data fro my view.  The combined numbers correspond to a document in my view.  If there is a document, I would like the title displayed in a text box, else nothing in a text box.  Hope this is clear enough.

Here is an example:

9 V    <--- think of the V as the combo box
110 V

Combined value: 9110
The title: Title2

My View

9109   Title1
9110   Title2
9111   Title3
0
 
LVL 3

Expert Comment

by:sravikiran
ID: 13425485
OK,

suppose the hidden field name is "FieldTotal". This field shoul dhave the following computed formula
MyField1 + MyFiield2

Now, suppose the field that you want to show the title is "Title". Use the following formula

Dtitle:= @DbLookup( "" ; <servername> : <databaseName>; <viewname>; FieldTotal ; Subject );
@if(@iserror(Dtitle);"";Dtitle);

The above formula assumes that you want to show the Subject of the document in the title field. You can substitute the last argument with the field name that you would like to show its contents in the title field.

In addition, you can use FieldTotal to show single category view
0
 
LVL 13

Expert Comment

by:CRAK
ID: 13427086
Hi, I'm awake again....
sravikiran is right, but its not the whole story. I assume you are not all that expirienced yet in programming notes.

I assume you already have documtens ready holding the search keys (equivalent for FieldTotal) and the value to be retrieved. I'll refer to them as "Key" and "Title" resp. You'll need to put these in a view with (at least) two columns:
Col 1: Key (sorted or @DbLookup won't find anything!)
Col 2: Title

Name the view e.g. "(TitleByCode)". The brackets will hide the view for users.

The @DbLookup should now like like:
Dtitle := @DbLookup( "" ; ""; "(TitleByCode)"; FieldTotal ; 2);
@If(@Iserror(Dtitle);"";Dtitle);

The 2nd parameter ("") will tell @DBLookup to use the current database. Be carefull NOT to refer to a server in a web-based application!

The formula should work well in a computed (text) field.
0
 

Author Comment

by:DawG25
ID: 13429386
Thanks for the help, I forgot about the key having to be the firs column.  The formula works great in a computed field, but I would like it to be editable.  Can this be done in a regular text field?
0
 
LVL 13

Expert Comment

by:CRAK
ID: 13433474
Not neccessarily the first column, but the first SORTED column!

So if the comboboxes are changed, you want the @DbLookup to do the job AND be able to change the result?

What happens if the comboboxes get changed after you have edited the title? Overwrite?

It can be done. Haven't decided to do that in @Formula, Lotusscript of Javascript though.... Thinking of JS and some help of two additional hidden fields: one to act as the computed field (i.e. the current field) and one to act as a flag to keep track of the last change: combobox of title. The translation event of the editable field could then determine wether or not to copy the original title.

Do realize that the edited title won't update the document holding the key!
0
 
LVL 3

Expert Comment

by:sravikiran
ID: 13435124
Create a computed hidden field ("Title") that has the @dblookup formula. This field holds the title of the document.

Now, create an editable field "TitleDisp". In the onLoad even of the form, write the following Javascript

document.forms[0].TitleDisp.value = document.forms[0].Title.value

Note:Make sure to use the field names in the Javascript the same case as you have for the field name.
0
 
LVL 13

Expert Comment

by:CRAK
ID: 13436868
That would reset the edited TitleDisp to the original value if the document is opened again....
0
 
LVL 13

Accepted Solution

by:
CRAK earned 800 total points
ID: 13437231
I have constructed a situation here to accomplish what you (probably) need.
I have used different fields though:

Combo1 and Combo2 are my comboboxes.
DefaultTitle and EditFlag as hidden editable text fields (make sure that html is generated for these field too, or javascript will fail!)
myTitle as the editable field that should either inherit the default title, or keep the edited one.

Both combobox fields should hold this javascript code in the onChange event:
   document.forms[0].EditFlag.value='0';

note: Javascript is case sensitive; EditFlag is one of the fieldnames.

DefaultTitle has following formula (both Default and Translation). It's the formula that you tested/approved earlier:
   Ttl:=@DbLookup(""; ""; "(TitleByKey)"; Combo1 + Combo2; 2);
   @If(
      @IsError(Ttl);
      "n.a.";
      Ttl)

note: (TitleByKey) is my viewname.

EditFlag has a default value "0"

myTitle has a default and translation formula:
   @If(
      EditFlag = "0";
      DefaultTitle;
      myTitle)

It also has following javascript in the onKeyDown event:
   document.forms[0].EditFlag.value='1';

I bet this'll do the job perfectly (if you have all fieldnames correct).
0
 
LVL 3

Expert Comment

by:sravikiran
ID: 13445006
Yep, that will reset the value when you open the document. If you want to show the title in an editable field and have the user change it and keep the changes you change the code in my posting to :

if (document.forms[0].TitleDisp.value =="") {
document.forms[0].TitleDisp.value = document.forms[0].Title.value ;
}

This makes sure that if the user has modified the value (or accepted the default value), don't replace it.
0
 
LVL 13

Expert Comment

by:CRAK
ID: 13447604
That'll get you in trouble if users change their mind (they always have these nasty habits...) and prefer the original title again.
My code handles that too!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
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.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Suggested Courses

571 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