Calcfield for just some entry types

zeonzeon Member Posts: 130
On Item Ledger Entry I have a flowfield called Complaint (boolean), that checks if a production order has a complaint job. The calcformula is:
Exist("Production Order" WHERE (Status=CONST(Finished),No.=FIELD(Prod. Order No.),Complaint job=FILTER(<>'')))

My problem is that I only want to calculate the field if Item Ledger Entry."Entry Type"=Output, and display that on Form 38 to avoid the field being calculated if entry type=consumption etc. Is that possible? Is there an alternative method of doing it?

zeon

Comments

  • MBergerMBerger Member Posts: 413
    if it's just on that particilar form, you could do it in the OnFormat trigger of the field.
    if "entry type" <> "entry type"::"output" then
      text := '' ;
    
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    write this code on form

    Complaint := FALSE;
    IF "Entry Type" = "Entry Type"::Output THEN
    CALCFIELDS(Complaint);
  • BeliasBelias Member Posts: 2,998
    Flowfields on form are calculated even if you don't write "CALCFIELDS" code under the form...if the field on the form is visible, flowfields are calculated automatically: for this reason is not a good idea to put a lot of FF on a tabular form.
    i don't know a way to achieve your needs with flowfields, but you can calculate the field manually putting code under the form
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    den we can write like this

    IF "Entry Type" <> "Entry Type"::Output THEN
    Complaint := FALSE;
  • BeliasBelias Member Posts: 2,998
    den we can write like this

    IF "Entry Type" <> "Entry Type"::Output THEN
    Complaint := FALSE;

    First of all, compliant mustn't be a FlowField...and after that we can use your code like this
    IF "Entry Type" <> "Entry Type"::Output THEN
     Complaint := FALSE
    ELSE BEGIN
      //Here calculate the value of compliant basing to calcformula written by "zeon"
    END;
    
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    zeon wrote:
    On Item Ledger Entry I have a flowfield called Complaint (boolean),
    zeon

    Complaint is already a flowfield and calculated with calcformula

    y shd we calculate again?
  • BeliasBelias Member Posts: 2,998
    Belias wrote:
    Flowfields on form are calculated even if you don't write "CALCFIELDS" code under the form...if the field on the form is visible, flowfields are calculated automatically: for this reason is not a good idea to put a lot of FF on a tabular form.
    i don't know a way to achieve your needs with flowfields, but you can calculate the field manually putting code under the form

    because as i said, flowfields are always calculated when they're visible on a form (we CAN'T selectively calculate fields when running forms), so we have to change the fieldtype from flowfield to normal, and then proceed with a manual calculation. it's not a perfect solution, but it's the only one i know.
    I'll make an example, i know my english is not perfect: try to create a tabular form using wizard with table g/l account.
    select next and then balance from the field list (balance is a flowfield). you'll see that values are calculated.
    now, click esc and finish the creation wizard. press f9 and check if there are CALCFIELDS word in the code.
    After this click view, properties and check the value of "calcfields" property (it's undefined)
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    yes flowfields are calculated automatically in forms

    as u said we can take normal fields and calculate them in forms

    i think we can do false them in forms if we dont want to calculate them in above case by writing
    IF "Entry Type" <> "Entry Type"::Output THEN
    Complaint := FALSE;

    is dere any problem in this?
    i mean in performance or etc?
  • BeliasBelias Member Posts: 2,998
    yes flowfields are calculated automatically in forms

    as u said we can take normal fields and calculate them in forms

    i think we can do false them in forms if we dont want to calculate them in above case by writing
    IF "Entry Type" <> "Entry Type"::Output THEN
    Complaint := FALSE;

    is dere any problem in this?
    i mean in performance or etc?

    yes, there are performance issue and if the field is used somwhere else the data COULD not be consistent

    P.S.: =D> for your 100th post! mohana_cse06
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    [quote="Belias
    yes, there are performance issue and if the field is used somwhere else the data COULD not be consistent

    P.S.: =D> for your 100th post! mohana_cse06[/quote]

    thanq Belias.

    am in learning stage.soon i want to become expert lik al of u.. :mrgreen:
  • zeonzeon Member Posts: 130
    Hi guys,

    Thanks for all your inputs!

    I have put the code on the form and changed the field to Normal, BUT the only issue left is that users want to set filter on the form by F7 (on the complaint field), and when doing that the form displays no entries at all, so there is a trade-off in using this solution?!

    It weird that the property AutoCalcField on a field on a form is not working?!
  • DenSterDenSter Member Posts: 8,304
    Well think about it. Instead of having data in the field in the database, you chose to put code on the form, and display values that are calculated by the form. At this point, the data is not in the table, it is on the form. If there is no process to actually put data into the field itself, the field will always have its default value that is set up on a table level, which if you did not change the initvalue, it should be FALSE. So, if you filter on TRUE, then of course you're not going to see any records.
Sign In or Register to comment.