This topic is locked

Copy record the second column change

1/7/2026 22:48:46
PHPRunner General questions
C
carrie3800332 author

When I use copy record the second no(項目編號) column is copy original value,
I change first category_id(認證人員編號) column then second no(項目編號) column become null,
This no(項目編號) column when add use lookup and when copy record no need change value
I try use field events add as below ,but the same situation,what methods can be used to solve this?

  1. client before
    if ($_REQUEST['action'] != 'copy') {
    params["value"] = this.getValue();
    }
    2.server
    if ($_REQUEST['action'] != 'copy') {
    $result["upper"] = strtoupper( $params["value"] );
    }
    3.client after
    if ($_REQUEST['action'] != 'copy') {
    ctrl.setValue( result["upper"] );
    }

Thanks a lot.

rc_resourcedetails6_add before.jpg
rc_resourcedetails6_add after.jpg
rc_resourcedetails6_add lookup.jpg
rc_resourcedetails6_add lookup events.jpg
ChatGPT 1/7/2026

It seems like you're facing an issue with the behavior of the "copy record" feature in PHPRunner, particularly with how the "no (項目編號)" column is handled when you change the "category_id (認證人員編號)" column.

Here’s a structured approach to resolve this issue:

Understanding the Problem

  1. Copy Record Behavior: When you copy a record, the values of most fields are duplicated from the original record. However, changing the "category_id" seems to affect the "no" field.
  2. Lookup Field: If "no" is a lookup field, it might be dependent on the value of "category_id". When you change "category_id", the lookup might not find a valid corresponding value for "no", hence it's being set to null.

Solutions

  1. Field Events: Since you've already tried using field events, ensure that you're handling the "copy" action correctly. The logic should ensure that the "no" field retains its value when copying the record.

    Here’s a refined approach:

    Client Before Event:

     if ($_REQUEST['action'] == 'copy') {
    // Retain the original value of the no field when copying
    params["value"] = this.getValue(); // Assuming this is the field for no
    }

    Server Event:

     if ($_REQUEST['action'] == 'copy') {
    // Set the upper value for no field if needed
    $result["upper"] = strtoupper($params["value"]);
    }

    Client After Event:

     if ($_REQUEST['action'] == 'copy') {
    ctrl.setValue(result["upper"]); // Set the value back to no field
    }

  2. Modify Lookup Logic: Check how the lookup for the "no" field is defined:

    • Make sure that it doesn’t depend on the "category_id" in such a way that it forces a null value when the "category_id" changes.
    • Verify that the lookup table/query is correctly configured to return the appropriate value based on the conditions you expect.


  3. Database Triggers/Procedures: If applicable, consider using database-level triggers or stored procedures to handle the copy operation, ensuring that the correct values are preserved during the copying process.


  4. Debugging: Add some logging or alerts within your events to see the values of "category_id" and "no" at different points. This might help you identify why "no" is being set to null.


  5. PHPRunner Support: If you've tried these approaches and the issue persists, consider reaching out to PHPRunner's support or community forums. They may have encountered similar issues and can provide specific guidance tailored to your version and setup.



By following these steps, you should be able to maintain the integrity of the "no" column when copying records. Good luck!

C
carrie3800332 author 1/8/2026

It still have same situation,what methods can be used to solve this?

Thanks a lot.