Solved

Simple webagent question...

Posted on 2001-06-04
40
192 Views
Last Modified: 2013-12-18
Hi experts,

I'm a newbee with designing agents for the web. I want to create a button on the web that will change a fieldvalue within the form that is opened (on the web).
On the form is a field called FIELD_A. I want to change this field by using the action button on the web.
I have create a agent called "ChangeField" (manually from Agent List) that will set this value with the command:

FIELD FIELD_A := "1"

I'm want to start this agent with a button with the formula:

@Command([ToolsRunMacro];"ChangeField"

When pushing the action button on the web, the browser is returning a Error message:

The page cannot be displayed
There is a problem with the page you are trying to reach and it cannot be displayed.

What is wrong with this simple agent ?

Greetings,

Bob
0
Comment
Question by:oosterbaan
  • 15
  • 9
  • 9
  • +2
40 Comments
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6152330
Instead of running agent use this in action button

FIELD Test := "Value";
Test


~Hemanth
0
 
LVL 5

Expert Comment

by:snocross
ID: 6152681
Listening...
0
 
LVL 1

Author Comment

by:oosterbaan
ID: 6152948
Sorry HemanthaKumar,

But this is not setting the value of the field....

Greetings,

Bob
0
 
LVL 5

Expert Comment

by:snocross
ID: 6153073
Do this!

FIELD Test := Test;
@SetField("Test";"Value here")
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6153119
Then there is only onething left

create an html button like this and set the value

<input type=button name=SetValue value=SetValue onClick="document.forms[0].FielName.value='some value' ">

This should work.

BTW, do you have that field which is in context visible to the user ??? If so then the previous comment of mine shoudl work.

PS: Check the prop Automatically refresh fields of Form

~Hemanth

0
 
LVL 1

Author Comment

by:oosterbaan
ID: 6153423
Hi guys,

The field wasn't visible, that's why I could not see that the value was changed. You where right about the changing of the field, but the document is not saved...that's the problem I think, so what must I do to set the value permanently. I also have add @Command([FileSave]) after changing the field, but it's not saved...

Greetings,

Bob
0
 
LVL 5

Expert Comment

by:snocross
ID: 6153577
Hmmm... do you have a SaveOptions field that may be preventing you from saving?  My code looks like this and it always works:

FIELD Test := Test;
@SetField("Test";"Value here");
@Command([FileSave]) ;@SetField("SaveOptions";"0");@Command([FileCloseWindow])
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6153615
There is no reason why it shouldn't save if it is a simple form.

Do you have any SaveOptions field set to "0". This would not save anything.

Also check the default value of the field in context, remove any formula in it.

Also check if any field is giving you an error like validation failure

~Hemanth
0
 
LVL 1

Author Comment

by:oosterbaan
ID: 6153690
Hi guys,

I'm really confused here...

I have a SaveOption field, but the value is "1" (computed when composed)
When I remove the Saving of the form, I can see the value change, so that's working.. Now I add only the @Command([FileSave]) to the code.. This generates a error message in the browser. When I add the @Command([FileCloseWindow]), the error message in the browser is gone, but document is not saved....

I really do not know what to do next...I will create a new test database and try it again....
0
 
LVL 1

Author Comment

by:oosterbaan
ID: 6153708
I have created a blank database with a simple form (only one field on it). This field has a computed when composed field (@Unique).
I have created a action button that's changing the value. I can see this is happening, but again....not saving it...

Do you guys have a sample of your database...Can you send it to me ?

Greetings,

Bob
0
 
LVL 5

Expert Comment

by:snocross
ID: 6153712
Ok, what else is your button doing besides the code we have given?  Try making to code very simple for a test.  Also, are you attempting to execute any agents when the document is saved?  It sounds like perhaps something is trying to run but is failing.
0
 
LVL 5

Expert Comment

by:snocross
ID: 6153717
Are you sure it's not saving?  If your URL says something like ?OPENFORM at the end then whenever you hit REFRESH it will attempt to compose a new blank copy of the form.  Do you have a view that you are looking at to reference the document after it's created?
0
 
LVL 1

Author Comment

by:oosterbaan
ID: 6153783
Is there a way to send the database to you, so you can evaluate it ? I will rais the points, it's driving me mad overhere (-:
It's really not saving and I have done everything you said.

Greetings,

Bob
0
 
LVL 1

Author Comment

by:oosterbaan
ID: 6153808
After takeing a good look, the URL is not trying to open a Form (?OpenForm), but it's opening a document (?OpenDocument) Can this cause the problem...?
0
 
LVL 5

Expert Comment

by:snocross
ID: 6153857
Sure, you can send it to snocross19@hotmail.com.  (?OpenDocument) is fine.  Basicly when you see OpenDocument that means you are opening a document that has already been saved whereas (?OpenForm) is like pressing CREATE or COMPOSE to open a blank document that has never been saved.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6153861
What is the value of saveoptions for the opened document and how are u hiding the saveoptions field ???

Sure you can send the database to hemanthakumark@bigfoot.com



0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6153866
or send it to snocross. He might be able to help you.
0
 
LVL 1

Author Comment

by:oosterbaan
ID: 6153910
Hi guys,

I have send the database to both of you... Thanks for that...
When you have found it, we will work something out with the points....

Greetings,

Bob
0
 
LVL 5

Expert Comment

by:snocross
ID: 6153948
I can't open it with my hotmail account.  Can you try sending it to patrick_bachmann@barberfoods.com
0
 
LVL 1

Author Comment

by:oosterbaan
ID: 6154025
It's on his way....
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6154097
Change the default value to
DEFAULT Test := @Unique;
Test

THis should work.

0
 
LVL 5

Expert Comment

by:snocross
ID: 6154141
@Unique is not supported on the web.  Try putting some other default value like "xyz" or something...
0
 
LVL 1

Author Comment

by:oosterbaan
ID: 6155105
I know Snocross,

The document is generated in the LN client and I want to change this field in another value on the web....

Greetings,

Bob
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 6155133
Bob,
Here's a way to code the button in JavaScript :

var form=document.forms[0];
form.FIELD_A.value="any value";
form.submit();

The first line defines your form in a variable.
The second line sets the value of the field to "any value". If you want to set the value to something you calculate, let me know. I'll translate the calculation to JavaScript if needed.
The third line will submit the form to the server, thus saving it.

Regards,
JM
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 6155137
Bob,
Is your field set to be computed or editable ? If it is computed, it won't show on the web and will simply be presented as HTML-text. In this case the JavaScript function won't work, unless you have checked the "Generate HTML for all fields" option of the form.
0
 
LVL 1

Author Comment

by:oosterbaan
ID: 6155185
Thanks jerrith,

It's a computed when composed field... But, do I need Javascript for setting the value of one field ?

Greetings,

Bob
0
 
LVL 1

Author Comment

by:oosterbaan
ID: 6155186
Thanks jerrith,

It's a computed when composed field... But, do I need Javascript for setting the value of one field ?

Greetings,

Bob
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 6155259
Bob,
I've found what is causing your error. There's nothing wrong with the @formula code. The only problem is that this action can only be done when the document is in edit mode. So here's what to do :
1. Switch to edit-mode using an edit button with the formula @command([EditDocument]). Hide this button in edit mode.
2. Hide the action button to reset the field when the form is in read mode (pressing this button in read mode will cause an Internal Server Error message)

Alternatively, you can set the document to automatically be opened in edit mode in the form properties dialog (2nd tab)

All the code that is needed for your set button is :
FIELD FIELD_A:="value you want";
@Command([FileSave]);
@Command([FileCloseWindow]);

Regards,

JM
0
 
LVL 1

Expert Comment

by:tgebruik
ID: 6155269
Why not use JavaScript for this????
This way you can let the Client setting the Field value, and not the Server....
Just make a button that uses Javascript like this:

var f=document.forms[0];
f.FIELD_A.value="1";

This also works inside the Notes Client!!!

And Field validation can be done in JavaScript BEFORE sending the page back to the Server......
(we all can see the benefit for that)
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 6155312
Hello tgebruik,
You may have noticed that I've allready suggested a JavaScript function in an earlier comment as well.
In this case there won't be a gain in performance, since all that is done is change the value of one field and then immediately save the form. Changing the value in JavaScript and the submitting the form would result in the same thing.
In any case for the JavaScript function to work, the form needs to have the property "Generate HTML for all fields" set too, since this is a computed field. Otherwise you will get an error, because the field is not an object on the form.
By the way, the @Unique function will also work when used on the web. I've tried this with an action button with the following formula :
FIELD FIELD_A:=@Unique;
@command([FileSave]);
@URLOpen("/" + @ReplaceSubstring(@subset(DbName;-1); " ":"\\";"+":"/") + "/" + @Text(@DocumentUniqueID) + "?OpenDocument")

The last line is just put there to automatically reopen the document to show the changed value.
0
 
LVL 1

Author Comment

by:oosterbaan
ID: 6155525
Jerrith,

Are you creating a new form on the web or do you adjust a excisting one ? I'm trying to adjust a field in a document that already excist in the database.
The reason why I'm don't want to use Java, is that I don't know how to wright Java, and I want know how this is done, for future designs.

Greetings,

Bob
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 6155703
I've tested the way you want it to be:
First I create the form in the client with the default value, being a random text generated by the @Unique function.
Then I open the document from the web, click on the edit button to open the document in edit mode.
Thirdly click the button to update the field value and save the document.

No problems, works like a charm.

I've tried to update the field when the document is in read mode, and then I get an HTTP error stating there's an internal server error. So I'm guessing, this is your problem.
0
 
LVL 1

Author Comment

by:oosterbaan
ID: 6155722
OK jerrith,

This is almost what I want...It's quit simple and I don't know, why it isn't working with me.
The difference between your Test and mine is that I'm using a computed when composed Field and I'm not opening the document for editing. I want a button that can be pressed by the author, that will make the change...

Are you using @Formulas for al you have done ?

Greetings,

Bob
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 6155744
Yes, it's all @Formulas and you must open the document in edit mode to perform any change to the fields. If the document is opened for reading only it won't work.
That's why you first have to switch to edit mode (with the edit button) and then press the other button to perform the update.
So to summarize :
1. Edit button, formula @command([EditDocument]), Hide when edited
2. Update button, Hide when read, formula :
   FIELD FIELD_A:="value you want";
   @Command([FileSave]);
   @Command([FileCloseWindow]);

First press the edit and then the update button and it will work fine.
0
 
LVL 1

Author Comment

by:oosterbaan
ID: 6155770
What I really want is to change the status of the document. So the field that must change isn't visible on the web (and in the notes client).I don't want to open the document manually in the Edit mode. This must be done in one go:

- Get the document in EditMode
- Change the value of the "Status" field
- Save the document

I have tried to do this in one formula, but my problem is that the document is changing the value of the field, but not saving anything...

Greetings,

Bob
0
 
LVL 8

Accepted Solution

by:
Jean Marie Geeraerts earned 100 total points
ID: 6155796
If this is the case, the best way to go about it is to write an agent using LotusScript and call this agent from your action button.

So in your action button you have @Command([ToolsRunMacro];"(Update Status)")

Then create the agent with the following properties :
1) Run : "Manually From Agent List" (this will hide the agent from the actions menu)
2) Run Once (@commands may be used)
3) Put the following script in the Initialize event:

Sub Initialize
   rem Get the current web document
   dim session as new notessession
   dim doc as notesdocument
   set doc=session.documentcontext

   rem update the field
   doc.FIELD_A = "whatever value"

   rem save the document
   call doc.Save(True, False)
End Sub

This will work regardless if the document is being edited or not.
Don't forget the brackets () around the agent name.

Greetz,
Jean Marie
0
 
LVL 5

Expert Comment

by:snocross
ID: 6155927
Maybe I should not do it this way but what I always do is AUTOMATICALLY ENABLE EDIT MODE on all my documents then I have two of every field.  One field for example will be editable and the second will be computed (therefore locked).  Next I use hide-when formulas to hide the editable fields when necessary.  This way I can still process hidden fields and things like that and hide fields based on user priveleges etc.

-Snocross
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 6155951
I do that in certain cases as well, snocross. Especially when users can only change parts of a document, then I use a dispFIELD to display the field to users that are not allowed to modify it. All these fields are computed with as formula simply the name of the field they display.
It's great for limiting access to certain parts of a document, but I don't use it for all fields in my forms.
For my client also, for most applications I need to foresee an anonymous read access, so I rarely use the automatic edit function.
0
 
LVL 1

Author Comment

by:oosterbaan
ID: 6157215
Thanks guys for all your comments,

I have tried the option that jerrith gave me, and it worked out well. I still do not understand why it's not working using a simple method, using the options like written above in this question, but I don't want a endless discussion.
Again, thank you very much guys,

Greetings,

Bob
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 6158573
The reason why is that you cannot update a document while it is in read mode, unless you use an agent, which will change the backend document, thus the document in the database.
You can compare the documentcontext as referred to in the agent with the notesuidocument in a notes client. When you save the referenced document, it will also change the notesdocument in the database.
No need to think about it, it's the way Iris wanted it ;-)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now