How to write agent that do dblookup formula when require key field to be entered?

i currently need to create 2 different button, one for fill in values to KeyField. Which will enter other fields, say keyfield2

the 2nd button will do lookup, using values in KeyField and keyfield2, and enter it in LookupField.

I was not able to combine into one button, as it will give errors, due to the keyfield2 will need to be refreshed, upon entering of value in keyfield1, but this will cause the lookup for getting value of LookupField to give an error, as value in keyfield2 was null during the first refresh.

any tips on how to overcome this?tq

Subject: How to write agent that do dblookup formula when require key field to be entered?

You could:

use a hide-when on the 2nd button… so it won’t be visible if the 1st field isn’t populated… or

at the start of the code in button two, look to see if button one has already been pressed… or

at the start of the code in button two, look to see if the first field has been populated in the uidoc.

Subject: RE: How to write agent that do dblookup formula when require key field to be entered?

tq Stan,appreciates your reply but I was looking whether I can use @command or @function first?tq

Subject: why to store the keys… ?

If you know the values for your keyFields in your first button,creating one single button is easy… you’ll probably not have to check the keyFields anymore…

Subject: How to write agent that do dblookup formula when require key field to be entered?

on your second button you have code like this:

@if(keyfield1=“”;“Please enter value for 1st field first”;@DbLookup(“”;“”;“lookupview”;keyfield1;2))

Subject: RE: How to write agent that do dblookup formula when require key field to be entered?

tq Stan, but I was wondering whether I can only have one button instead.

Regards

Subject: RE: How to write agent that do dblookup formula when require key field to be entered?

If the user selects one thing, then needs to select another… that is two things… if the user can select both items at once, then that is one question… for example:

McDonald’s Meal #1, includes hamburger and fries so user can just say Meal #1

So Will, do you need to ask one, or two questions?

:slight_smile:

Subject: RE: How to write agent that do dblookup formula when require key field to be entered?

Guest you are right, coz 2nd question depends on 1st question. Thought there is some way I can make the 2nd lookup after all data required is entered initially:

1st action: to enter field1, field2 will do lookup with values from field1

2nd action: field3 will be entered based on values entered in field1 and field2, i.e field1 + field2 is the key for lookup value in field3.

tq.