Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 371
  • Last Modified:

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.
0
Pucktarget
Asked:
Pucktarget
  • 4
  • 3
  • 2
  • +3
1 Solution
 
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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
 
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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