Running function is header skipping function in line.

tabularasatabularasa Member Posts: 22
Hello everyone.

I have a function that I run from the onDelete trigger of the sales header. It asks the user if some tasks should be performed and then performs these.

I have a similar function in the sales line in th OnDelete trigger which performs similar function, asks the user and then performs a subset of the header function.

My problem is that I don't want the Function in the Sales Line to run when the sales Header is deleted. I have tried.

1. Using the Currfield function and setting the condition if Currfield <> 0 then SalesLineFunction
2. Creating a variable in the sales Line Form (page) that calls a function in the sales line that assigns a global variable. The problem is that immediately after that function is done the global variable is reverting to opposite value.

Any ideas.

Many thanks ..

Comments

  • David_SingletonDavid_Singleton Member Posts: 5,479
    You should not be asking questions in the ondelete trigger. Think of a different way to do this and redesign your logic. Since you have not explained what you are doing its hard to give guidance though on how to redesign it.
    David Singleton
  • FDickschatFDickschat Member Posts: 380
    Don't create a variable in the form, create it in the sales line table, where your function is in the OnDeleteTrigger.
    Create a SetParameter Function in SalesLine. Only run your function in case the parameter is true/false.
    Frank Dickschat
    FD Consulting
  • tabularasatabularasa Member Posts: 22
    Basically there are entries linked to the sales header and the sales lines. The sales invoice was created based on the value of these entries. When the invoice is deleted the status of these entries should be reverted to it's former state if the user confirms that as sometimes he might not want that.
  • tabularasatabularasa Member Posts: 22
    FDickschat wrote:
    Don't create a variable in the form, create it in the sales line table, where your function is in the OnDeleteTrigger.
    Create a SetParameter Function in SalesLine. Only run your function in case the parameter is true/false.
    The problem with the second option (similar to what you are suggesting) is that all variables in the sales line are cleared before going through OnDelete trigger. I find creating a field in sales line table kind of lame solution.
  • BeliasBelias Member Posts: 2,998
    in the setparameter, you can declare a temporary table of subtype "integer" and insert a dummy record in it...
    then, check if the record is present. It should work.
    BTW: don't ask for user interactions in ondelete/insert/modify triggers, if possible...and try to not code under the form, but just under the table, if it is suitable for your business logic.
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • tabularasatabularasa Member Posts: 22
    Many thanks I'll try this. I always try to leave the forms for coding and keep it to the table. But this seemed like a last resort. Not sure how to avoid asking the customer through function triggered from the ondelete trigger As the business logic is to modify related entries when the sales invoice is deleted.
  • tabularasatabularasa Member Posts: 22
    This worked Many Thanks.
Sign In or Register to comment.