View Single Post
Farling
Senior Member
 
Join Date: Mar 2013
Location: Greater London, UK
Posts: 2,623

Old June 1st, 2020, 02:11 AM
Quote:
Originally Posted by apoca6 View Post
Next question, looking at my data, some of the fields were split so instead of alignment, i have a 4 or 5 columns with variations, some for C some for G (in the case of CG), is it possible to add multiple items to one field and have them concatenate? so 'C' 'blank' 'blank' 'blank' 'G' in the alignment field would parse as 'CG' into RW?
You can use the new "custom columns" function. You create a new column, and write some javascript which defines how the value will be generated for this new column.

So you could write a function which will examine various other columns and decide what the single new combined value should be.

For example, the following javascript for a custom column merges several columns into a single D&D 5E spell duration field

Quote:
row.column('duration/1/duration/amount') + ' ' + row.column('duration/1/duration/type') + ((row.column('duration/1/concentration') == 'true') ? ' (C)' : '')
and for the time field we have a more complex expression

Quote:
var r = row.column('time/1/number') + ' ' + row.column('time/1/unit')

if (row.column('time/1/condition') != '')
r += ' (' + row.column('time/1/condition') + ')'

if (row.column('meta/ritual') != '')
r += ' (R)'

r
and for the description, we need to merge several fields including some HTML:

Quote:
var a = row.column('entries/1')
var b = row.column('entries/2')
var c = row.column('entries/3')

var d = ''
if (a != ' ') d += '<p>' + a + '</p>'
if (b != ' ') d += '<p>' + b + '</p>'
if (c != ' ') d += '<p>' + c + '</p>'

d
Note that I'm a complete amateur at javascript, so there could be easier ways to do the above things.

Farling

Author of the Realm Works Import tool, Realm Works Output tool and Realm Works to Foundry module

Donations gratefully received via Patreon, Ko-Fi or Paypal

Last edited by Farling; June 1st, 2020 at 02:24 AM.
Farling is offline   #555 Reply With Quote