Link to home
Start Free TrialLog in
Avatar of andyhines
andyhines

asked on

Problem with @FileSave

Hi,

I'm trying to write a shared action in a Lotus Notes database. We will use this database for processing of expenses claims. In this case the action submits the expenses claim after first running through some validation checks on  certain fields.
What I want to do is save the document (so that my @Abstract gets calculated and I can count the amount of text in the justification field), apply the validation checks giving the option to Cancel and correct or Continue and then finally (assuming they choose "Continue") I update the status to Submitted and assign a reference number then save again.

Problem is that while the first save works the second one doesn't. If I take the first save out then the second one works fine. I have a vague memory that this is some sort of restriction but I can't remember the details.

Can anyone advise how to get round this or maybe a better way to do what I am trying.

I guess I could make my ' Notes' RTF a plain text field instead but that would mean I couldn't attach any receipts etc.

Thanks Andy

Current code is :

FIELD FullName := "";
FIELD CurrentNum := 0;
FIELD Prefix := "";

@Command([FileSave]);
FIELD saveoptions:="0";

@If(EFL_AmountPP > EFL_MaximumAmount; answer:=@Prompt([YesNo];"Outside Expense policy limits";"The meal cost per person is higher than allowed for in the expenses policy. You can either continue anyway or cancel and review the claim. Continue ??");"");
@If(answer=0; @Return(0); "");

@If(EFL_AdditionalNotesRequired = "Yes" & @Length(EFL_AdditionalNotesAsText) = 0; answer:=@Prompt([YesNo];"Justification Required";"This type of expense claim requires a justification to allow approval. The 'Notes' field appears to be empty. You can either continue anyway or cancel and review the claim. Continue ??");"");
@If(answer=0; @Return(0); "");

@If(@Adjust(EFL_Date;0;3;0;0;0;0) < @Now;  answer:=@Prompt([YesNo];"Historic Expenses Claim !";"The Expenses policy states that claims should be submitted within 3 months of being incurred. You can either continue anyway or cancel and review the claim. Continue ??");"");
@If(answer=0; @Return(0); "");


FIELD FullName := @Name([Canonicalize];@UserName);
FIELD ShortName := @Name([CN];@UserName);

FIELD seq_UNID := @DbLookup("":"NoCache";"":""; "Person_Lookup";FullName;3) ;
@If(
      @Length(seq_UNID)!=32;
      @Prompt([Ok];"Error";"Can't find an entry for you in the Employees view - please notify IT.");
      @Do(
                  @SetField("EFL_Status";"Submitted");
                  FIELD CurrentNum:= @GetDocField(seq_UNID;"ExpenseRef");
                  FIELD Prefix := @GetDocField(seq_UNID;"ExpensePrefix");
                  @SetField("EFL_Reference";Prefix+"-"+@Text(CurrentNum)) ;
                  @SetField("EFL_ExpenseManager"; @GetDocField(seq_UNID;"ExpenseManager"));
                  @SetDocField(seq_UNID; "ExpenseRef";CurrentNum+1)
                  )
      );
@Command([FileSave]);
FIELD saveoptions:="0";
@Command([FileCloseWindow])
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

Is any of the fields an Authors field? If the current author of the document is not in that field the first time the document is saved, he cannot save the document again, not being one of the authors. So the first time he has to be present, the full canonical name, and if you want to prevent updates once saved again, you have to remove the name before the second save. It might be easier just to add another Authors field that you remove right before the 2nd save.
Avatar of andyhines
andyhines

ASKER

Hi. I do have an Authors field on the document but the code above doesn't touch it (yet)
It is populated with my full canonical name and the name of an Admin group.

I don't believe this is the fault because if I create a doc, enter a description, save it manually, update the description, save it again and then close it I do see the updated description.

Thanks - Andy
ASKER CERTIFIED SOLUTION
Avatar of QuinF
QuinF

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
Ahhhh ... I thought SaveOptions = 0 meant 'Save without prompting'. Guess I'd better read the documentation again. I'll try this in the morning. Thanks - Andy
Well spotted!
Many thanks.