How can I save computed fields?

I want to generate a sequential number in my Mailin database. I created a view, sorted (descending) by the sequential number field. I’m also using @dblookup to get the first highest number then add one. Everything works fine so far.

I want to create agent that will assign tickets to 12 team members in orderly manner. First ticket will go to analyst #1, 2nd ticket to, analyst #2 and so on.

I created two hidden fields in a form to set a counter. The first field - Incremented - has this formula…

SequentialNumber := @If(@IsNewDoc & @IsDocBeingSaved; @Subset(@DbColumn(“” : “NoCache”;“”:“”;

“LastNumber”; 1); 1); “”);

@If(@IsNewDoc & @IsDocBeingSaved; @If(Incremented != “”; Incremented; SequentialNumber = -999; 0; !@IsNumber(SequentialNumber); 1; SequentialNumber + 1); Incremented);

I also have a Counter field that’s computed with this formula:

tmp:=@modulo(increment;12)+1;@if(@iserror(tmp);0;tmp).

Everything works fine when I create new documents from the database. But, when new mail arrives, the two field values are not calculated. It appears that the document always have to be saved for the field values to be calculated.

If anyone has any idea of what I can do to get the computed fields saved, i would really appreciate it. I’ve searched the forum and haven’t found anything to work yet.

TIA

Subject: How can I save computed fields?

Sounds like you want to move the code into an agent running on new mail, assigning the numbers as the mails come in. Make the field editable and hidden with a computed for display field as well.

Subject: RE: How can I save computed fields?

Thanks Dan! I made the ‘Counter’ field editable with computed for display, moved the code into an agent. I run the agent on new mail and nothing happened. For some reason, the field values are not calculated or saved. Is there anything I’m missing?

I appreciate your patience!

Subject: RE: How can I save computed fields?

When you say nothing happened, do you mean the agent didn’t run at all?

You need to change the agent slightly of course, as the agent needs to assign the value to the field, rather than just computing to the correct value, so if you haven’t done that make sure you have. Post the agent formula if you’re unsure

Dan

Subject: RE: How can I save computed fields?

Thanks again. I made changes to the agent but still not able to run it. Here is the code in the agent… . I really appreciate your help!

FIELD Count := Count;

FIELD Incremented := Incremented;

SequentialNumber := @If(@IsNewDoc & @IsDocBeingSaved; @Subset(@DbColumn(“” : “NoCache”;“”:“”;

“LastNumber”; 1); 1); “”);

@If(@IsNewDoc & @IsDocBeingSaved; @If(Incremented!= “”; Incremented; SequentialNumber = -999; 0; !@IsNumber(SequentialNumber); 1; SequentialNumber + 1); Incremented);

Count :=@Modulo(incremented;6)+1;@If(@IsError(tmp);0;tmp);

message := “RE: New Help Desk Ticket has been assigned to you. Please double click on the doclink to view the request.”;

@If(Count = 1; @MailSend(Analyst1; “”; “”; “Help Desk Ticket: Pending ticket”; message; “”; [IncludeDoclink]); “”);

@If(Count = 2; @MailSend(Analyst2; “”; “”; “Help Desk Ticket: ticket”; message; “”; [IncludeDoclink]); “”);

@If(Count = 3; @MailSend(Analyst3; “”; “”; “Help Desk Ticket: ticket”; message; “”; [IncludeDoclink]); “”);

@If(Count = 4; @MailSend(Analyst4; “”; “”; Help Desk Ticket: ticket"; message; “”; [IncludeDoclink]); “”);

@If(Count = 5; @MailSend(Analyst5; “”; “”; “Help Desk Ticket: ticket”; message; “”; [IncludeDoclink]); “”);

@If(Count = 6; @MailSend(Analyst6; “”; “”; “Help Desk Ticket: ticket”; message; “”; [IncludeDoclink]); “”);

@Command([FileSave]);

@Command([FileCloseWindow]);SELECT @All

Subject: RE: How can I save computed fields?

As this is now an agent acting on new messages, you don’t need the checking for new document or anything, and you’re not setting the fields at all (well, you are at the beginning of the agent, but you haven’t set the values yet)

SequentialNumber := @Subset(@DbColumn(“” : “NoCache”;“”:“”;

“LastNumber”; 1);1);

Incremented:=@if(SequentialNumber = -999; 0; !@IsNumber(SequentialNumber); 1; SequentialNumber + 1);

Count :=@Modulo(incremented;6)+1;@If(@IsError(tmp);0;tmp);

FIELD Incremented:=Incremented;

FIELD Count:=Count;

message := “RE: New Help Desk Ticket has been assigned to you. Please double click on the doclink to view the request.”;

@If(Count = 1; @MailSend(Analyst1; “”; “”; “Help Desk Ticket: Pending ticket”; message; “”; [IncludeDoclink]); “”);

@If(Count = 2; @MailSend(Analyst2; “”; “”; “Help Desk Ticket: ticket”; message; “”; [IncludeDoclink]); “”);

@If(Count = 3; @MailSend(Analyst3; “”; “”; “Help Desk Ticket: ticket”; message; “”; [IncludeDoclink]); “”);

@If(Count = 4; @MailSend(Analyst4; “”; “”; Help Desk Ticket: ticket"; message; “”; [IncludeDoclink]); “”);

@If(Count = 5; @MailSend(Analyst5; “”; “”; “Help Desk Ticket: ticket”; message; “”; [IncludeDoclink]); “”);

@If(Count = 6; @MailSend(Analyst6; “”; “”; “Help Desk Ticket: ticket”; message; “”; [IncludeDoclink]); “”);

Think that should do it, you don’t need to save the documents, the agent’ll do that for you.

Dan

Subject: RE: How can I save computed fields?

Thanks! I modified the agent and it’s working like a charm! I really appreciate your help!

Now, the client wants the tickets to be moved to the analysts folders. I’ve six folders called “Analyst1” to “Analyst6”. Can you please help me how to move new e-mailed documents to these folders??

Do I need another agent or can I do it with the one that’s already there?

Thanks Again!

  • TB

Subject: RE: How can I save computed fields?

You can do it in the same agent I reckon.

If you look in the help under folders, you’ll come to the @addtofolder command which should do what you want

Subject: RE: How can I save computed fields?

I used the @addtofolder command in the agent and everything works Great now. Thanks for all your help!!

Subject: RE: How can I save computed fields?

Are you certain when the agent acts on documents that are mailed in, that either @IsNewDoc or @IsDocBeingSaved will ever return True?

Following your logic, I think that this code:

SequentialNumber := @If(

@IsNewDoc & @IsDocBeingSaved;

@If(

	Incremented!= "";

	Incremented;

	SequentialNumber = -999;

	0; 

	!@IsNumber(SequentialNumber);

	1;

	SequentialNumber + 1

);

Incremented

);

will always set SequentialNumber to the value in Incremented (which may be “”), whent he agent runs on documents mailed into the database.

Subject: RE: How can I save computed fields?

You’re right, Cesar. The Incremented field always returns “” value on documents mailed into the database.

Subject: RE: How can I save computed fields?

Is this what you expect, or should Incremented have a value other than “” when a doocument is mailed in?

Subject: RE: How can I save computed fields?

The Incremented should always have the last number from the “LastNumber” view. This works fine when I create new mail from the database. But, whenever documents are mailed in, Increment displays “”.

Subject: RE: How can I save computed fields?

Then your problem must be that the document that is being processed by the agent is not a new document. A new document is one that has not yet been saved but if the document is laready in your mail-in database, it must have been saved at least once. You need to solve the logic there.

Subject: RE: How can I save computed fields?

I go back to my suggestion: Don’t try to modify the mail document - modify another document that you create purely for tracking the last assigned analyst.

Subject: RE: How can I save computed fields?

Don’t use computed-for-display. That will not be saved because, like the name says, it’s for display.

Use a regular computed field.

Subject: RE: How can I save computed fields?

You don’t even need to use the mail document to keep track of numbers. Create a document that tracks the last assigned analyst number and when you send the document that was just mailed in, check that number to see who should be next on the list. You can even use the same document to keep track of analyst names who are available that day (one may be on vacation or sick for example). Then the number is incremented and if it goes beyond the last number in the list, reset it to 1 and pull the first name from your list of available analysts.