Modify table from Form Trigger.

awatharam86awatharam86 Member Posts: 49
Hi guys,

Is there any possibilities to modify table from Form Trigger. I mean modify table while getting records from table. Any idea guys..? Plz share..

Comments

  • vaprogvaprog Member Posts: 1,141
    Hi awatharam86

    What is your business need?

    What did you try so far and why did it fail?
  • awatharam86awatharam86 Member Posts: 49
    Hi vaprog,

    I'm trying to modify table record from Card Form. Each time retrieving table record, I want to modify that record in Form - OnAfterGetRecord trigger. I tried to assign value to a field and added CurrForm.SAVERECORD() function in this trigger but system is asking to rename the record. This is not what I wanted. I want each time while retrieving table record, I want to assign value to a field and save it in table. And while to view table list, I want to see record with new modified field. Any idea? Please share..
  • SavatageSavatage Member Posts: 7,142
    What are you trying to modify and why does it have to be modified by a form?

    You need to explain more about whatever you are doing and why you would rather use code on a form instead of a table.
  • awatharam86awatharam86 Member Posts: 49
    this is how my functional team asked me to do. I'm also got no idea how to develop it since i'm also new here.
    This is what I developed here.

    file.php?mode=view&id=3988&sid=30b176fe00d39f96dfd6bf83f58bfaf8
  • vaprogvaprog Member Posts: 1,141
    Do you really need those calculated values as fields on the table? Otherwise, just use global variables (if they need to be modifyable) or place the calculating expression in the SourceExpr property of the control showing the value.

    Are all these values fields in your table? If Yes, you probably should drop one of each tripple. If you need to keep them all, add OnValidate trigger code to the table fields to keep them consistent at all times.

    If you still need to modify the record in the OnAfterGetRecord trigger of the form, try MODIFY(TRUE) rather than CurrForm.SAVERECORD. The record has just been retrieved from the database and the form's controls are not yet updated.
  • KishormKishorm Member Posts: 921
    You should not do this on the form but instead set the field values in the OnValidate() trigger of the various fields - and then make sure you VALIDATE the fields if setting them in code.
  • awatharam86awatharam86 Member Posts: 49
    adding MODIFY(TRUE) also creating problem

    file.php?mode=view&id=3990&sid=30c509ded374c55a49fd5bf5cb89b9c4
  • SavatageSavatage Member Posts: 7,142
    OnAfterGetRecord is used to get information not to write information.

    You can use that trigger to calculate variables that depend on the current record.

    I don't think you can do it there and even if you could I don't think it's a good way of handling whatever you are trying to achieve.
    Every time someone opens that form reading & writings will constantly be occuring.

    Perhaps you should rethink on how to accomplish this task.
  • awatharam86awatharam86 Member Posts: 49
    Yes, I think itz true. We cannot actually modify record each time Form retrieving it from table. I've tried most of the method and all return error. So itz true.
Sign In or Register to comment.