More interesting support questions to help you customize your EvolutivoFW application.
How can I launch a Generative AI prompt with information from a record?
The conversation went more or less like this:
It should be easy to do too. We create the prompt using the messages module, where you can substitute the variables as needed to parameterize the prompt, then a business action that launches the prompt and shows the result. You can use the credentials module to save the API key. I set out to give it a try.
As I suspected it was easy enough to create a Business Action that merged a message template and showed the result in the browser because we already do that in the email process. This is what the business action looks like:
javascript:ExecuteFunctions('getEmailTemplateDetails', 'templateid=50035').then(function (response) {
let tpl = JSON.parse(response);
ExecuteFunctions('getMergedDescription', 'template=' + encodeURIComponent(tpl.body) + '&crmid=$RECORD$').then(function (response) {
let prpt = JSON.parse(response);
ldsModal.show('Merged Prompt', prpt, '');
});
});
Where the template ID (50035 in the example above) is:
And the result looks like this:
Now I had to add some code to send the merged template to OpenAI and show the result instead of the merged template. I added two commits, one includes a PHP library to access OpenAI as a service, and the other adds a service inside EvolutivoFW to use generative AI (corebos_genai()
) and a function to call that from the browser; genaiPrompt
.
The modified business action looks like this:
javascript:ExecuteFunctions('getEmailTemplateDetails', 'templateid=50035').then(function (response) {
let tpl = JSON.parse(response);
ExecuteFunctions('getMergedDescription', 'template=' + encodeURIComponent(tpl.body) + '&crmid=$RECORD$').then(function (response) {
let prpt = JSON.parse(response);
ExecuteFunctions('genaiPrompt', 'prompt=' + encodeURIComponent(prpt)).then(function (response) {
let chat = JSON.parse(response);
ldsModal.show('GEN AI Response', chat, '');
});
});
});
Where you can see that I call the new genaiPrompt
function and get this result:
Simple and effective. A world of possibilities!
How can I set default values in the creation of a User?
There is, as far as I know, an undocumented functionality of the Field Mapping Business Map. This map serves the purpose of defining field values when creating a record from another record. So we are in record A of some module and we create a new record in module B with the knowledge that we are coming from a certain record. Using the values in the origin record we can do all sorts of calculations or we can simply set values in the new record with any calculation.
This map triggers based on its name, in the case of the example above the name would be A2B
, in general, {OriginModule}2{DestinationModule}
.
Now the trick. When you set the name of the map the same module like, {ModuleA}2{ModuleA}
the application understands that you are trying to set default values for the creation of records in ModuleA
. This gives immense power for setting default values for a record based on many conditions. This functionality also works in the Users module, so, if we create a Field Mapping Business Map with the name Users2Users
we can set default values for the creation of Users.
<map>
<originmodule>
<originname>Users</originname>
</originmodule>
<targetmodule>
<targetname>Users</targetname>
</targetmodule>
<fields>
<field>
<fieldname>first_name</fieldname>
<Orgfields>
<Orgfield>
<OrgfieldName>FIRSTNAME HERE</OrgfieldName>
<OrgfieldID>CONST</OrgfieldID>
</Orgfield>
</Orgfields>
</field>
</fields>
</map>
Powerful and customizable!
Photo by Neil Thomas on Unsplash