Default Value formula problem

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.
PucktargetAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

qwaleteeCommented:
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
PucktargetAuthor Commented:
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
qwaleteeCommented:
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
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

HemanthaKumarCommented:
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
PucktargetAuthor Commented:
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
qwaleteeCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PucktargetAuthor Commented:
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
Sjef BosmanGroupware ConsultantCommented:
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
yoshi78Commented:
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
WhiteLotusCommented:
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
HemanthaKumarCommented:

"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
PucktargetAuthor Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.