In logic hook differentiate between record Imported and created with GUI

Is there a variable/flag I can access in a before_save logic hook which will let me determine if the record being saved was created using the SuiteCRM GUI or using the Import functionality?

I have a scenario where if the user is creating a record with the GUI, I auto-populate some fields. If the user then deletes the entries pre-populated, I can conclude that the user does not want the pre-populated data to be stored and set the field contents to empty.

But if the record is being created via Import, there is no user check on the individual fields so I want the logic hook to set the field contents to default values.

How can I tell, in a before_save logic hook, if a record being saved was created by a user using the SuiteCRM GUI or via the Import functionality?

Got it

The $_REQUEST array contains an entry with the key ‘module’

If the record creation is being done using the SuiteCRM GUI, the $_REQUEST[‘module’] entry is the name of the module.

If the record creation is being done using the Import functionality, the $_REQUEST[‘module’] entry is ‘Import’.

So a simple if condition:

if ( $_REQUEST['module'] == "Import' ) {
    ... code goes here ...
}

Does the trick!

2 Likes