AnsweredAssumed Answered

I Need Help making a custom One-to-Many relationship field required.

Question asked by mstetka on Apr 4, 2016
Latest reply on Apr 13, 2016 by cmutek

Hi all,

 

I'm operating on an on-demand instance of SugarCRM enterprise, and have created a custom module "Salesbrand" (One) which is related to the Quotes module (Many). This relationship was created via the Studio. In studio, the relationship is named "brand_salesbrand_quotes_1"

 

The relationship works as expected, when creating the quote, the user is able to pick the Salesbrand.

 

The next step is to make the field required, and that's where I'm stuck. Since it's an on-demand instance, I need to make the changes via the module loader, and I have no idea how to debug the issue. I've looked through the documentation, and every example I see uses '<module>' in the place where the module name would go, but they don't give any guidance as to what the valid values are, or where to find them...

 

I've added the number_of_sites_c to this just to test if a simple custom field would work using my current method, but it also isn't being made required.

My code to edit the vardefs is as follows, in a file named 'brand_name_required.php'

<?php
$dictionary['Quote']['fields']['brand_salesbrand_quotes_1_name']['required'] = true;
$dictionary['Quote']['fields']['brand_salesbrand_quotes_1_id']['required'] = true;
$dictionary['Quote']['fields']['number_of_sites_c']['required'] = true;
?>

My Package Manifest code is as follows:

<?php
    $manifest = array(
        'acceptable_sugar_flavors' => array('CE','PRO','CORP','ENT','ULT'),
        'acceptable_sugar_versions' => array(
            'exact_matches' => array(),
            'regex_matches' => array('(.*?)\\.(.*?)\\.(.*?)$'),
        ),
        'author' => 'SugarCRM',
        'description' => 'Installs my files to the accounts module',
        'icon' => '',
        'is_uninstallable' => true,
        'name' => 'Require Salesbrand in Quotes Module',
        'published_date' => '2016-03-04 2016 10:20:04',
        'type' => 'module',
        'version' => '1',
    );
    $installdefs = array(
        'id' => 'package_salesbrand_required_relationship',
        'copy' => array(
            0 => array(
                'from' => '<basepath>/brand_name_required.php',
                'to' => './custom/Extensions/modules/Quotes/Ext/Vardefs/brand_name_required.php',
            )
        ),
    );
?>

 

Thanks in advance for your guidance.

 

Edit:

If there is any information that isn't here that would help me get this accomplished, please let me know. I'd be happy to provide additional information, I just need to know what to provide.

Outcomes