Skip to main content
simply more productive

The Data Specialist

Thanks to our intuitive transformation designer, you can convert data effortlessly to a variety of formats without knowing how to program. It’s not only efficient, it’s also easy to use.
Up to 100,000 records can be processed with the freeware version!
Flowheater Chart

Use parameter in AddDays Heater

More
3 years 4 months ago #3632 by JD Cox
I'm using this .NET Script heater (Execute Per Row) and it seems to be working fine:
public object DoWork()
{
    if (InValues.Length == 0)
    throw new ArgumentException("min. 1 input parameters expected!");
    
    DateTime mydate = (DateTime)InValues[0].GetDateTime();    //order date
    bool prior2 = (bool)InValues[1].GetBool();                             //prior to 2pm
    int myday = (int)mydate.DayOfWeek;
    int ret = 1;
    int days = 1;

    switch (myday)
    {
        case 5: //friday add 3 days if after 2pm
            if (prior2 == false)
                ret = 3;
                break;
        case 6: //saturday add 2 days
            ret = 2;
            break;
    }
    //set flowheater parameter days to advance export date
      Parameter["days"].Value = ret;
    return null;
}
The problem is with the parameter $days$ in the number value field in the AddDays heater.
I get this error on the first row:

H: AddDays    The value [$days$] could not be converted into a number.

If I'm unable to use the parameter in the AddDays heater would I be able to calculate the date add in the .NET heater and return that value?
 

Please Log in or Create an account to join the conversation.

More
3 years 4 months ago - 3 years 4 months ago #3633 by FlowHeater-Team
Replied by FlowHeater-Team on topic Use parameter in AddDays Heater - Post(3633)
Usually “Each row Heaters” should be executed before common heaters are processed. But in case you using conditions ( IF-THEN-ELSE Heater ) or for example Set Parameter Heater and this chain triggers the AddDays Heater the FlowHeater Parameter DAYS isn´t right initialized. In this case you´re always using the calculated DAYS from the previous record!

If modified your script, see below. Now the .NET Script Heater returns the calculated date. Please have a look to the attached example.

File Attachment:

File Name: script-add...8-14.zip
File Size:8 KB


C# .NET AddDays script example
Code:
public object DoWork() { if (InValues.Length == 0) throw new ArgumentException("min. 1 input parameters expected!"); DateTime mydate = (DateTime)InValues[0].GetDateTime(); //order date bool prior2 = (bool)InValues[1].GetBool(); //prior to 2pm int myday = (int)mydate.DayOfWeek; int ret = 1; int days = 1; switch (myday) { case 5: //friday add 3 days if after 2pm if (prior2 == false) ret = 3; break; case 6: //saturday add 2 days ret = 2; break; } return mydate.AddDays(ret); }

Best wishes
Robert Stark
Last edit: 3 years 4 months ago by FlowHeater-Team.

Please Log in or Create an account to join the conversation.

More
3 years 4 months ago #3634 by JD Cox
Thanks Robert,

The .NET Script got me where I needed to be.

JD

Please Log in or Create an account to join the conversation.

Time to create page: 0.269 seconds
FlowHeater Logo

FlowHeater - The Data Specialist

Efficient data integration and transformation with FlowHeater – the perfect solution for a seamless transfer of your data.

Legal information

Support & Contact

Contact

Phone:
0951 / 9933 9792

eMail:
This email address is being protected from spambots. You need JavaScript enabled to view it.


Copyright © 2009-2024 by FlowHeater GmbH. All rights reserved.