Solved

Default Value formula problem

Posted on 2003-12-05
12
362 Views
Last Modified: 2013-12-18
Hello all.  I have been banging my head over this problem and cannot seem to get it to work.

I have a field "txtSubmittedBy" that is an editable dialog that uses the address dialog list for choices.  It has a default value based on the user and has some exiting script that updates the uses phone number when changed.

My problem is that I want to have a default value of the user who creates the document in the txtSubmittedBy field.  I achieved this successfully by putting @Name([CN];@UserName in the default value of the field.  My problem is that when some else opens the document to view, the default value was changing to their name and replacing the original.  We want this field to be a dialog list because uses may need to change that field manually.

I tried to circumvent the default value by placing this formula in the default value:

@If(@IsNewDoc;@Name([CN];@UserName);txtSubmittedBy!="";txtSubmittedBy;"Unknown")


However, all this does is return the "Unknown" string value when it is reopened for editing.  

Is there any way to get the original value to stay in the field until the user manually changes it?

Thanks in advance all.
0
Comment
Question by:Pucktarget
  • 4
  • 3
  • 2
  • +3
12 Comments
 
LVL 31

Expert Comment

by:qwaletee
ID: 9884092
YOu must be doing something really weird. Default formula only runs when the field doesn't already have a value.  That would be true if the document is first being composed, or if you added the field to a form later (in which case, even though the document exists, the field did not previously exist, and the deafult value runs.

It appears to ne that you may have uysed a COMPUTED field with this formula, and set up a button that displays the address dialog, and forces the field value to change.  What you probably want to do is make the field COMPUTED WHEM COMPOSED, so that the formula acts as only a default.  COMPUTED WHEN COMPOSED fields essentially have DEFAULT formula, but are not editable.  Regular computed fields have a formula that applies both as a default and as an update ("translation")
0
 

Author Comment

by:Pucktarget
ID: 9884165
The field does exist on open of the form and pops up with that user in it.  You are right, this is weird, it would be really easy if they did not want to be able to reselect a user for the field.  Another confusing thing is that we are using that field to generate an informational "phone number" field, so we have script that runs on exit of the field to truncate the field and find the new phone number.

Would the dialog list be generating a null value somehow?  That is why when it reopens the document the field value disappears?
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9884346
Null strings are still considered "values" and will not cause DEFAULT to run again.  If you use @UnAvailable or @DeleteField, that will cause the field to be eliminated completely, and DEFAULT would run again.

I need to understand your structure better.  Please confirm:

Main form -- has a field named txtSubmittedBy.  Definition:
* EDITABLE (not computed/computed for display/computed for compoased)
* Type is DialogList
* Dialog list definition (third tab) specifies "uses Address Dialog for choices"
* Has a DEFAULT formula of @If(@IsNewDoc;@Name([CN];@UserName);txtSubmittedBy!="";txtSubmittedBy;"Unknown")
* Has NO translation formula

There is no subform involved, or other form that s used via @DialogBox.  The dialog box is opened because Notes simply does that for DialogList fields with "Address dialog for choices."

There is no other formula on the form that references txtSubmittedBy

There is no LotusScript on the form

Can you confirm all of the above?
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9884464
You pointed out that

>has some exiting script that updates the uses phone number

So could be that some other script in querysave or recalc event is destroying the field value. Similarly translation is not removing the content..

Quickly check the doc properties in the view that what this field holds when it is saved

~Hemanth
0
 

Author Comment

by:Pucktarget
ID: 9884488
Here is what I can confirm for you..thanks for the help btw.

Field: txtSubmittedBy

Type: Dialog List and is Editable

Dialog Control: "Uses Address Dialog for choices" and the options selected are: Display entry helper button and Refresh fields on keyword change.

There is no input transalation formula.

There is LotusScript on exit of the field which truncates the Notes name:

Sub Exiting(Source As Field)
      Dim workspace As New NotesUIWorkspace
      Dim uidoc As NotesUIDocument
      Dim intCount As Integer
      Dim strRequester As String
      Stop
      Set uidoc = workspace.CurrentDocument
      Call uidoc.Refresh
      
      strRequester=uidoc.FieldGetText("txtSubmittedBy")
      
      intCount=Instr(strRequester,"/")
      
      If intCount>0 Then
            intCount=Instr(strRequester,"/")
            strRequester=Left(strRequester,intCount-1)
            Call uidoc.FieldSetText("txtSubmittedBy",strRequester)
      End If
      
      uidoc.Save      
      
      Call uidoc.refresh
      
End Sub

There is also some LotusScript on a submit button, which submits the form and sends out a link to certain indiviuals.

Thanks!!
Puck
         
0
 
LVL 31

Accepted Solution

by:
qwaletee earned 150 total points
ID: 9884574
OK, one test.  Create a new test document with the form.  Change the field value to some test name via the address dialog, or just via text entry.  Save it, and exit.

Open the test document again.  From what you wrote above, it will change the field value from the test name you enetered into either Unknown or your name, depending on which verson of the formula you are using.

Is that the case?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Pucktarget
ID: 9884895
I created the test doc with just 2 fields.  I changed the doc via the dialog list, saved it and exited.

When I reopened the form it was back to my name.  

I don't know if it makes a difference but we are using a submit button to post the document to a view once completed, so each saved document appears as a different record.

0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 9888281
After you save the document, look in the Document Properties. What's the value of txtSubmittedTo? Correct or Wrong, so you know whether it happens while closing or reopening.
0
 
LVL 1

Expert Comment

by:yoshi78
ID: 9891383
First question:
<quote>Is there any way to get the original value to stay in the field until the user manually changes it?</quote>

@If(@IsNewDoc;@Name([CN];@UserName);txtSubmittedBy)
meaning if its a new doc, get the current user, else get the saved user.

if you want to also keep track of who's been using the doc, then I would place a seperate field, say user_List, and append the current user to it.
@if(@IsNewDoc;@Name([CN];@UserName);txtSubmittedBy+","+@Name([CN];@UserName))(don't hold me to this one, i'm a ls kinda guy)
Then you can show the values as a combobox selected by formula(second tab) fieldname(user_List), make sure sorting is off.
Not exactly what you want I know.
HTH
Yoshi
0
 

Expert Comment

by:WhiteLotus
ID: 9895784
Try my baby in a normal text field :-)

@If(@IsNewDoc;@Text(@Name([CN];@UserName))+ " at " + @Text(@now);@ThisValue+","+@Text(@Name([CN];@UserName)) + " at " +@Text(@Now));
rem {@If(@IsDocBeingSaved;@Name([CN]; @UserName);modifier)};
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9896771

"I don't know if it makes a difference but we are using a submit button to post the document to a view once completed, so each saved document appears as a different record."

DOes that mean that you might be dropping of this field while posting it as a different record ?

0
 

Author Comment

by:Pucktarget
ID: 9898882
Hi Qwaltee, (and thanks to other Experts as well for your comments).

Your test had me thinking about how the document was being saved.  I was saving it correctly and the field was properly holding its default value and is did not change as you pointed out.

However, my problem is in that I was trying to send a link to the newly submitted document when the user hits a submit button on the form.  The button saved the doc but then sent a link to a new blank document.  Your comments about the default value and to make a dummy form and test steered me in the right direction.

I will post a follow up question regarding sending a link after closing a form via NotesUIDocument class (if it is possible).

Thanks for your help.

Pucktarget
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

758 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