Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for relate fields in update value backend actions #576

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

erickbadilla
Copy link

@erickbadilla erickbadilla commented Nov 28, 2024

Description

This PR introduces support for updating values through backend actions for relate fields in SuiteCRM 8. Previously, the system did not support updating these fields, limiting the functionality of working with relationships in modules. With this enhancement, relate fields can now be managed more comprehensively via the backend.

Motivation and Context

The official SuiteCRM documentation previously mentioned that backend value updates were not supported for relate fields. This change aims to extend the current capabilities and ensure that relate fields are also manageable in the backend. This is particularly beneficial when creating custom logic to update the relate field.

Specific Implementation for Relate Fields

To address the limitation of updating relate fields, the backend requires a specific response structure to ensure proper updates. The run method in the backend handler must provide the response data in the following format to update relate fields:

public function run(Process $process)
{
    $options = $process->getOptions();
    $record = $options['record'];
    $attributes = $record['attributes'];

    $responseData = [
        'value' => json_encode([
            'id' => '72773dab-a9ee-e545-702a-674652570e09',  // The related record ID
            'name' => 'Test',  // The related record name
        ]),
    ];

    $process->setStatus('success');
    $process->setMessages([]);
    $process->setData($responseData);
}

How To Test This

  1. Create or Use Existing Module: Create a module with relate fields using the Module Builder.
  2. Apply Backend Update Logic: Use the custom backend handler to update a relate field through the backend.
  3. Check Updates: Ensure that the relate field updates correctly without any issues. Validate the change by reviewing the database and UI.

Example Test:

  • Create a new Contact record.
  • Relate the Contact to an Account.
  • Update a value in the relate Account field via backend logic using the appropriate structure.
  • Verify that the change is successfully reflected in both the database and the SuiteCRM UI.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • [x ] New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Final checklist

  • [x ] My code follows the code style of this project found here.
  • [x ] My change requires a change to the documentation.
  • [x ] I have read the How to Contribute guidelines.

@SuiteBot
Copy link

SuiteBot commented Nov 28, 2024

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants