Time display format

Hi,

We have a callback to ‘convert timer display’ into minutes only. Instead of displaying 5 days, 3 hours, etc

When we export the data via .csv it reverts back to how it was before.

time

Is there any way to apply the ‘convert timer display’ to the output file?

function leftPad(number, targetLength) {
var output = number + ‘’;
while (output.length < targetLength) {
output = ‘0’ + output;
}
return output;
}

let displayable_value = fragment_presenter.get_displayable_value();
if (!displayable_value) return;
if (displayable_value === “-”) {
fragment_presenter.set_displayable_value ("");
return;
}

let parts = displayable_value.split(" ");
let days = 0;
let hours = 0;
let minutes = 0;
for (let a=0; a < parts.length; a++) {
if (parts[a].startsWith (“day”)) {
days = parseInt (parts[a-1], 10);
}
if (parts[a].startsWith (“hour”)) {
hours = parseInt (parts[a-1], 10);
}
if (parts[a].startsWith (“min”)) {
minutes = parseInt (parts[a-1], 10);
}
}

if (days == 1 && hours < 6) {
days = 0;
hours += 24;
}
if (days > 0 && hours === 24) { // From time to time we get 1day 24hours remaining…
days += 1;
hours = 0;
}
/* let min_s = “00” + minutes;
min_s = min_s.substring (min_s.length-2, min_s.length);
let rv = “”;
if (days > 0)
rv = days + "d ";
/*
if (hours > 0)
rv += hours + "h ";
if (minutes > 0)
rv += min_s + "m ";

/
// rv += leftPad(hours, 2) + “:” + leftPad (min_s, 2);
// rv += " " + parts[parts.length-1];
rv = ((days
24)+hours)*60 + minutes;
fragment_presenter.set_displayable_value(rv);

Hi

As you have found, you cannot use a callback on an export - you would need to take your code and re-write as a field processor. Should be fairly straightforward - you will find the current value in params.input (rather than fragment_presenter.get_displayable_value()) - I would suggest a log of the value to check format) and at the end you simply "return rv " rather than fragment_presenter.set_displayable_value (rv).

Once coded up and saved, you should find the new field processor in the list against the field in the export columns page under “Processor”.

Hope this helps.

Richard

Hi,

Ah ok, so it cant be done solely within Build Studio.

I took a look, but its a bit beyond, just replacing references.

Sadly, we don’t have builders with experience with JavaScript, so this would not be possible.

Thanks, @richk