Question on messaging by Lucas, on 3/1/21:
Hi there, i again have a question
its about server-scripts or scripts in general, i mounted vol extensions locally with volumes: [ “./data/corredor/extensions:/extensions” ]
i see my script availible also inside docker corredor container when i do:
[root@lernpiloten corteza]# docker exec -it corteza_corredor_1 /bin/sh
~ $ ls -lah /extensions/
client-scripts/ server-scripts/
~ $ ls -lah /extensions/server-scripts/
eltern/
~ $ ls -lah /extensions/server-scripts/eltern/rec_update_eltern.js
-rw-r–r-- 1 root root 1.2K Jan 3 16:19 /extensions/server-scripts/eltern/rec_update_eltern.js
i tried different directory structures for the script to get picked up by corredor but i always get following logs from corredor:
[1609690787117] INFO (check): server-scripts service configured
[1609690787118] DEBUG (check): configuring cServer system API
apiBaseURL: “http://server/api/system”
[1609690787119] DEBUG (check): configuring cServer compose API
apiBaseURL: “http://server/api/compose”
[1609690787119] DEBUG (check): configuring cServer messaging API
apiBaseURL: “http://server/api/messaging”
[1609690787119] DEBUG (check): frontend settings
baseURL: “https://crm.lernpiloten.com”
[1609690787120] DEBUG (check): bundler enabled
output: “/tmp/corredor/bundler-dist”
[1609690787120] DEBUG (services.client-scripts): initializing
[1609690787120] DEBUG (services.server-scripts): initializing
[1609690787120] DEBUG (services.dependencies): initializing
[1609690787120] INFO (services.dependencies): initializing watcher
[1609690787127] INFO (services.server-scripts): reloading server scripts
searchPaths: [
“/extensions/”,
“/corredor/usr/”,
“/corredor/usr”
]
[1609690787128] INFO (services.client-scripts): reloading client scripts
searchPaths: [
“/extensions/”,
“/corredor/usr/”,
“/corredor/usr”
]
[1609690787130] INFO (services.client-scripts): processed
valid: 0
total: 0
[1609690787130] INFO (services.server-scripts): processed
valid: 0
total: 0
[1609690787154] DEBUG (gRPC): starting server
[1609690787155] INFO (gRPC): server running at 0.0.0.0:80
[1609690792591] DEBUG (grpc.server-scripts): returning list of server scripts
rpc: “List”
filter: {}
total: 0
[1609690792594] DEBUG (grpc.client-scripts): returning list of client scripts
rpc: “List”
filter: {}
total: 0
i created own namespace, maybe im missing something in order to load it in namespace other then crm?
do i have to follow Extensions :: Corteza Docs in order to implement scripts in my own namespace?
btw, script itself looks like:
export default {
label: ‘Record update changes Eltern’,
description: ‘erstellt komplettes Address und Namens Feld’,
triggers ({ before }) {
yield before('create', 'update')
.for('compose:record')
.where('module', 'eltern')
.where('namespace', 'lernpiloten')
},
async exec ({ $record }, { Compose }) {
// concat Adress field
const { strasse, haus_nr, plz, ort } = $record.values
const generatedstreet = [strasse, haus_nr ].filter(a => a).join(' ')
const generatedcity = [plz, ort ].filter(a => a).join(' ')
const generatedaddress = [generatedstreet, generatedcity ].filter(a => a).join('\n')
$record.values.generatedaddress = generatedaddress
// concat Full Name
const { vorname, name} = $record.values
const generatedname = [vorname, name ].filter(a => a).join(' ')
$record.values.generatedname = generatedname
// set links
let schuelerRecord
if ($record.values.kind.length > 0) {
schuelerRecord = await Compose.findRecordByID($record.values.kind, 'schueler')
if (schuelerRecord.values.eltern.includes($record.values.kind)) {
schuelerRecord.values.eltern.push(kind)
await Compose.saveRecord(schuelerRecord)
}
}
return $record
}
}