0
votes

I have two dialoglist fields Cutt_Start and Cutt_End, both of the fields has example choices of: January | 1
February | 2
March | 3
...
December | 12

Now, what I want to happen is that, when you select January on the Cutt_Startand March on the Cutt_End, it should prompt an error that Month2 should be next to Month1. I tried this code, but nothing happens.

If Cutt_Start = "January" & Cutt_End <> "February" Then
    Msgbox "Month2 should be next to Month1"
Else
    Msgbox "January to February selected"
End If

Can you help me?

3
Can you please add the full script code? In which event do you execute the script? How do you initialize the variables Cutt_Start and Cutt_End? Or do you want to read from the fields directly?Michael Ruhnau
Actually, that's all the script and I put it in the Exiting event of the Cutt_End field.drayl
Why don't you calculate the following month of Cutt_Start for your users instead of selecting them? Btw, your code above is LotusScript but won't work as you have to access fields per NotesUIWorkspace...NotesUIDocument...Document. But it is much easier to write a Formula and put it in "Input Validation" like suggested by Tode.Knut Herrmann
There seems to be some confusion here. You are referring your fields Cutt_Start and Cutt_End directly in your LotusScript which is invalid unless they are variable names. Please update your question otherwise the you won't get the answers you are looking for.Naveen

3 Answers

2
votes

As already mentioned, the stored field values are the ones right of the pipe. BUT: such fields are always text- fields!!!!

To do a computation, you need to transform the text to numbers...

_start := @TextToNumber( Cutt_Start );
_end := @TextToNumber( Cutt_End );
_res := _end - @Modulo(_start; 12)
@If( !@IsError(_res) &_res != 1; @Failure( "your message" ); @Success) 

This goes into the field validation of the Cutt_end- field.

If you need LotusScript (to have it in the QuerySave or the OnChange-Event of the field, then the code would be:

Option declare
Dim ws as New NotosUiWorkspace
Dim doc as NotesDocument
Set doc = ws.CurrentDocument.Document
If Cint(doc.Cutt_End) - CInt(doc.Cutt_Start) <> 1 then
    messagebox "your Message"
End if

This code does NOT contain any errror handler.

And as mentioned in the other comments: this for sure is not the right way to do it. If cut_end always has to be one month later, then simply change it to computed and write as value:

@If(Cutt_Start = ""; ""; @Text(@Modulo(@TextToNumber( Cutt_Start ); 12) + 1))

Then you would not need to make your check...

0
votes

The number to the right of the pipe character is the value of the field. The name to the left of the pipe is what is displayed to the user.

So if you just test that the numbers are sequential, and add a special case for Dec to Jan (1 comes after 12) then you should get the result you are looking for.

Note that the number value is still in text format so you'll need to cast it to a number first

If Cutt_End - Cutt_Start <> 1 Then Msgbox "Error!"

That said, if the Cutt_End must always be 1 month after Cutt_Start, then why have that field at all? Just calculate that field and make the user just choose the start month.

0
votes

Please check the following and put your code into the onchange event. For web and the notes client the onchange function behavior is different.

enter image description here