AnsweredAssumed Answered

PHP Script to create a csv of Sugar module names, fields, and labels

Question asked by Pat Pawlowski on Jul 14, 2017

I create a script that will create a CSV that lists all the modules, fields, and labels. I needed to provide this information to another team that will be integrating with Sugar and I couldn't find a convenient way to get output all of this. So I created a script based on cron.php that just gathers it together and sends it to a CSV. 

 

To download just go to the root of your Sugar folder and run: 

curl https://gist.githubusercontent.com/patpawlowski/10954eaa219e08eb35ac899f9be63bad/raw/f5fe9d26c93598b680a0806a98ce22f33f488ec2/sugar_create_field_list.php > sugar_create_field_list.php

Download and then just run:

php sugar_create_field_list.php

This will create a SugarFieldsAndLabels.csv file that looks like the sample below:

Module,Table,Field,Label
Accounts,accounts,id,ID
Accounts,accounts,name,Name
Accounts,accounts,date_entered,"Date Created:"
Accounts,accounts,date_modified,"Date Modified:"
Accounts,accounts,modified_user_id,"Modified by"
Accounts,accounts,modified_by_name,"Modified by"
Accounts,accounts,created_by,"Created by"
Accounts,accounts,created_by_name,"Created by"

There are also parameters on the class to set the output file name as well as modules to include or exclude. If the $ModulesToInclude array is empty then all modules will be included. 

private $FileName = 'SugarFieldsAndLabels.csv';
private $ModulesToSkip = array('SugarBox');
private $ModulesToInclude = array('Opportunities','Accounts','RevenueLineItems','TCX_Resources');

 

Have fun, 

 

-pat#

Outcomes