Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
var daysGained = $Database.Get({
    Parameters : {
        TargetSchema : 'HR',
        TargetTable : 'LeaveAllowance'
    },
    Columns : [{
        Name : 'DaysGained',
        Expression : "Sum(DaysGained)"
    }],
    Start : 0,
    MaxLength : 1,
    Where : {
        Criteria : [{
            Name : 'Employee',
            Value : $Initiator.Id
        }]
    }
});

$Xml.SetValue('GeneralInfo/EarnedDays', daysGained.Rows()[0]["DaysGained"]);

// OR

totalLeaves.Each(function () {
    $Xml.SetValue('GeneralInfo/EarnedDays', this.DaysGained);
});
Info

In the example below, offers by suppliers are grouped by the day they made with their count.

Example

Query with Expression - Advanced

Code Block
languagejs
var offerCountByDayTable = $Database.Get({
    Parameters : {
        TargetSchema : 'OFR',
        TargetTable : 'Offers'
    },
    Columns : [{
        Name : "Day",
        Expression : "DateTrunc('Day', OfferDate)"
    },
        {
            Name : "Amount",
            Expression : "Count(DateTrunc('Day', OfferDate))"

        }],
    Order : [
        {Name : "DateTrunc('Day',OfferDate)", Type : 'Ascending'}
    ]
});

offerCountByDayTable.Each(function () {
    console.info(this.Amount + ' offers made on the date ' + this.Day.toISOString());
});

See Also