Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

EIP - EIP Field Manager TakeAccepted for field fires twice - Why? 1

Status
Not open for further replies.

emaduddeen

Programmer
Mar 22, 2007
184
US
Hi Everyone,

Can you tell me why the EIP Field Manager TakeAccepted embed fires 2 times and is there a way to make it fire only one time with the correct value in the column?

When I run the program I change the value of sell price from 450 to 400. The first time the code fires the message displays 450 even though I changed it to 400. The 2nd time it fires, the message displays 400. What did I do wrong?

Here is the code I have in the embed:

Code:
! Calculate discount if sell price is < 0.
!-----------------------------------------

If Queue:TransactionDetailsList.TranDet:SellPrice < 0 |
Then
   Queue:TransactionDetailsList.TranDet:DiscountPercent = |
      0 - Queue:TransactionDetailsList.TranDet:SellPrice
   Queue:TransactionDetailsList.TranDet:DiscountAmount = |
      0 - ((Queue:TransactionDetailsList.TranDet:RegularPrice * Queue:TransactionDetailsList.TranDet:SellPrice) / 100)
   Queue:TransactionDetailsList.TranDet:SellPrice = |
      Queue:TransactionDetailsList.TranDet:RegularPrice - Queue:TransactionDetailsList.TranDet:DiscountAmount
Else
   Queue:TransactionDetailsList.TranDet:DiscountPercent = |
      100 - ((Queue:TransactionDetailsList.TranDet:SellPrice / Queue:TransactionDetailsList.TranDet:RegularPrice) * 100)
   Queue:TransactionDetailsList.TranDet:DiscountAmount = |
      (Queue:TransactionDetailsList.TranDet:RegularPrice - Queue:TransactionDetailsList.TranDet:SellPrice)
End

Queue:TransactionDetailsList.TranDet:LineTotal = |
   Queue:TransactionDetailsList.TranDet:SellPrice * Queue:TransactionDetailsList.TranDet:Quantity

message(Queue:TransactionDetailsList.TranDet:SellPrice)

Display()

Thanks.

Truly,
Emad
 
Hi Emad,

Are you checking for the Action in the EIPManager.TakeAccepted embed? The TakeAccepted will fire for all EIP columns and key actions. The best way to make sure the calculation is done once is to have a local variable you can set & check. But I think your problem is that you are not check the Action i.e.

CASE Action
OF EditAction:Save
...
END

Regards
 
Hi Emad,

I made a mistake in the equate. It should be in the EIPManager.TakeAction - before parent call :

IF Action = EditAction:Complete OR |
Action = EditAction:Next OR |
Action = EditAction:previous
...
END

You can explore the TakeCompleted method also which is called only for saving.

Regards
 
Hi ShankarJ,

I will look at the takeAction embed and experiment.

Thanks.

Truly,
Emad
 
Hi ShankarJ,

Almost there. Thanks for the help so far.

Using EIPManager.TakeAction and using the action variable traps the movement between the fields nicely, but I am not sure how to tell which field was completed. Could you tell me how to detect when Queue:TransactionDetailsList.TranDet:SellPrice is completed?

Also I noticed that the value in Queue:TransactionDetailsList.TranDet:SellPrice is 450 when the user changes it to 400 when the code fires. Maybe there is a way to update the value in the browse so the calculation will work.

Thanks.

Truly,
Emad
 
Hi Emad,

If you are trying to calculate a discount only when a particular column is updated then you should use the EditInPlace object for that column. In the EIP column properties you will find the class name which is by default EditInPlace::TranDet:SellPrice. So execute your code in
EditInPlace::TranDet:SellPrice.TakeAccepted(Action) - after parent call (which updates the value) and checking for the action first.

Code:
IF Action = EditAction:Complete OR |
   Action = EditAction:Next     OR |
   Action = EditAction:Previous
   ...
END

Regards
 
Hi ShankarJ,

Tried the code like this in EditInPlace::TranDet:SellPrice.TakeAccepted(Action) - after parent call and tabbing through the SellPrice field.

Code:
IF Action = EditAction:Complete OR |
   Action = EditAction:Next     OR |
   Action = EditAction:Previous

   message(Queue:TransactionDetailsList.TranDet:SellPrice)
END

The message never is displayed so I tried this to see what the action is.

Code:
message (action)

IF Action = EditAction:Complete OR |
   Action = EditAction:Next     OR |
   Action = EditAction:Previous

   message(Queue:TransactionDetailsList.TranDet:SellPrice)
END

It returned the number 1 twice after tabbing out of the SellPrice field. Shift + Tab returned a 2. Where do I find the equates for EditAction:Next, etc.

I could test for the numbers 1 and 2 in this embed but since it fires twice with the same number I may still be missing something.

I tried this:

Code:
IF Action = 1 OR |
   Action = 2

   message(Queue:TransactionDetailsList.TranDet:SellPrice)
END

At least the SellPrice value was correct but the code still fires twice.

Truly,
Emad
 
Hi Emad,

I posted the equates in the other thread :

Code:
EditAction:None     0
EditAction:Forward  1     ! Next field - Tab
EditAction:Backward 2     ! Prev field - Shift-Tab
EditAction:Complete 3     ! OK - Enter
EditAction:Cancel   4     ! Cancel - Esc
EditAction:Next     5     ! Next record - Down Arrow
EditAction:Previous 6     ! Prev record - Up Arrow 
EditAction:Ignore   7

Since the Selling price is not the last EIP column, you need to handle all Actions except 0, 4 & 7. An action of 3 will cause an AcceptAll i.e. generate an accept event on all EIP columns so you need to handle an one-time calculation by using a local procedure variable.

DiscCalculated BYTE(0)

IF NOT DiscCalculated
DiscCalculated = True
...
END

Regards
 
Hi ShankarJ,

Thanks for the help.

Everything is working now.

Truly,
Emad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top