Link to home
Start Free TrialLog in
Avatar of sharol
sharol

asked on

daily initialization

i need to make an initialization screen that will be edited daily. previous data entered on the same form need not be kept, it will be over-written. how do i control that the form will only be edited once a day. and the outline menu that displays the entry form is clicked again, it will only display the data entered and will not create another record?

thanks.
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

This can be managed in two ways: either does the Form look for a Document in a View so a second document cannot be created with that Form, or a formula checks for the actual Document not to be allowed to be edited again on same day.

To decide which method is better for you we need to know how is this Unique document picked up. Can you give us the formula which picks up that Unique document of the day?

Avatar of sharol
sharol

ASKER

the form is being called by an outline entry.
the values on that unique form will then be inherited to another form.

can we try both ways? thanks.
Avatar of sharol

ASKER

is there a better way to call the form to be able to do the checking?
SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Uups! Remove my debigging note.
use this:

FIELD LastModified:=LastModified;
FIELD SaveOptions:=SaveOptions;
@If(@Date(LastModified)=@Today;@Do(
@Prompt([OK];"Save aborted";"Dayly Notes can only be changed once a Day. );
@SetField("SaveOptions";"0"));@SetField("LastModified";@Today))


What?!

If you put the DayAdmin value into the profile functions, it gets assigned to a specific user.  Why bother?  Leave off the DayAdmin, and it just becomes global.

The UI here is suboptimal, because the document will always open in edit mode, even when it should not be edited.

Further, the values now can't ever be included in views.
Here's what I think is a better way.  Simple have a single document that will always be used, over and over.  We'll put it in a view, and alow users to open it.  The outline entry can retrieve it by getting it out of the view, and opening it.  The following scripts will control clearing it out once a day, and preventing edits more than once a day:

In QueryOpen:

Dim doc as notesDocument
Set doc = source.document
If doc.lastModified < today then
   forall item in doc.items
      item.remove
   end forall
elseif mode = 1 then' editing... but it was modified today!
   cancel = true 'prevent open in edit mode
End if



QueryModeChange:
If source.editMode then 'do nothing, we allow switch from edit mode to read mode
elseif source.document.lastModified < today then 'do nothing, we allow edits if doc is outdated
else 'switching to edit mode on a doc modified today is not allowed
  cancel = true
end if
Avatar of sharol

ASKER

still trying the options  you guys gave...thanks.

Zvonko, how do I create a profile document?
Avatar of sharol

ASKER

Zvonko, still having problems with the once a day editing. It displays the error message but still saves the new values more than once aday.
We do apply the prohibit function first after Profile Document saving is working correctly.
Does your Profile Document save the new data correctly now?

And please invoke your profile edit command with the third parameter, like I recommended:
@Command([EditProfile];"DalyNotes";"DayAdmin")

Avatar of sharol

ASKER

yes, it is already saving the data correctly. now, how do i control the editing of the profile into a once a day activity? thanks.
Oh, sorry, I forgot to mention: you need a new Field on the Profile Document Form. Name it "LastModified" and give it a type of DateTime. It can be hidden, but need not to be. You can make it ComputedForDisplay and enter Field name as formula: LastModified


The formula for QuerySave is still:

FIELD LastModified:=LastModified;
FIELD SaveOptions:=SaveOptions;
@If(@Date(LastModified)=@Today;@Do(
@Prompt([OK];"Save aborted";"Dayly Notes can only be changed once a Day. );
@SetField("SaveOptions";"0"));@SetField("LastModified";@Today))


Avatar of sharol

ASKER

What is SaveOptions for?
SaveOptions is a reserved Field name to prohibit saving of the document and to avoid the question on document exit whether to save the changes or not.
A value of "0" prohibits saving of document.
Therefore is saving of value "0" for that field not possible in regular Form field. It is only possible by Agents and formulas execution.

Avatar of sharol

ASKER

It can't be saved, SaveOptions has an error. (An operator or semi-colon was expected but none was encountered: 'SaveOptions')
Avatar of sharol

ASKER

I've fixed the error, but it is still saving more than once daily. When will LastModified field change its value?
You have not to create a field on the Form with the name SaveOptions.

Field LastModified should contain the date and time of last document save time.

Show me your actual QuerySave formula please.

What the heck woudl anyone use a field called LastModified for?  You haev @Modified, and NotesDocument.LastModified.  Sure, I know there's a bug in LastMdified, but I don't think that's teh issue here.
If you do use a LastMfieid field, make sure it is computed for display. If you have already made it computed/computed when composed/ediable, throw away the field and create a new field with a different name.
(Otherwise, LastModified may not stop anything until it is worked on THREE times in one day.)
Avatar of sharol

ASKER

I have followed what you guys suggested but it still won't work. Any other way to control the editing of the profile? thanks.
I don't like the profile idea.  See my earlier suggestion.


Show me your actual QuerySave formula please.

Avatar of sharol

ASKER

I just followed what u suggested....

FIELD LastModified:=LastModified;
FIELD SaveOptions:=SaveOptions;
@If(@Date(LastModified)=@Today;@Do(
@Prompt([OK];"Save aborted";"Terms can only be changed once a Day." );
@SetField("SaveOptions";"0"));@SetField("LastModified";@Today))

Avatar of sharol

ASKER

qwaletee, can we access the form other than clicking it from a view? what i need is for the user to just do one click(maybe from an outline) and the form will be displayed for editing or viewing already.
Sorry, there is a problem with ComputedForDisplay for the Field LastModified. Please make it Computed.

And extend the QuerySave function to this:

FIELD LastModified:=LastModified;
FIELD SaveOptions:=SaveOptions;
@If(LastModified!="" & @Date(LastModified)=@Today;@Do(
@Prompt([Ok];"Save aborted";"Terms can only be changed once a Day." );
@SetField("SaveOptions";"0"));@SetField("LastModified";@Today))


Also put a field SaveOptions Field on the Form with a DefaultValue of "1"


Hello sharol,

so far you did not state in this question how is the content in this document fetched for further processing.
I suggested ProfileDocument for the easy of fetching of profile document items in other document formulas.
But if you already use some document embedding method then we would like to see your method.

If you do not like Profile Documents, then you can get opened regular documents by this method:

1.) Select your document in the View.
2.) In client menu select: Edit->CopyAsLink->DocumentLink
3.) Open your Outline in Designer and put in your OutlineEntry:
Type=Link
Value=Press Paste Icon


Now your Outline Entry does open the linked document.

Avatar of sharol

ASKER

There's an error, "No formula specified for computed field: LastModified".
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry, take please this Form Events:

Sub QueryOpen(Source As NotesUiDocument, Mode As Integer, IsNewDoc As Variant, Continue As Variant)
      If (Not IsNewDoc) Then
            If (Mode = 1) Then
                  Continue = ((Clng(Date) - Clng(Source.Document.LastModified)) > 0)
            End If
      End If
End Sub


Sub QueryModeChange(Source As Notesuidocument, Continue As Variant)
      Continue = ((Clng(Date) - Clng(Source.Document.LastModified)) > 0)
End Sub


And if you like to go on with ProfileDocument, then put in Field LastModified this Formula:  LastModified

Yes, you can quite easily. You can include a formula that causes the document to open, or yuo can run an agent, and have the agent do it.

Here's some code that would do it:

viewName := "something or other.............";
formName := "something else or other.............";
check := @DbColumn(""; ""; viewName; 1);
@If(
  @IsError(check);
    @Command([Compose]; formName);
  @Elements(check) = 1;
    @Do(
      @Command([OpenView]; viewName; ""; "1");
      @Command([OpenDocument]);
      @Command([OpenView]; viewName);
      @Command([FileCloseWindow])
    );

  @Prompt([OK]; "Error"; "Duplicate entries found, please contact support")
)
Hello sharol,

thanks for the points.
But why the B?
Let me explain: your grading does multiply my expert points without to cost you extra.
Except that is this not a quiz where you grade the answer to be excellent or not, it is only a way to say Thank You for invested valuable time.

But you have a second chance :-)
Simply put a grade correction request and Community Support will do it for you:
https://www.experts-exchange.com/Community_Support/

Thanks in advance,
Zvonko

Split betwen Zvonko and Zvonko?!?!?!?!?!?!?!?!??!?!?!?!