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.
Flowheater Download

Parameters

More
2 years 8 months ago #3632 by JD Cox
Parameters was created 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
2 years 8 months ago - 2 years 8 months ago #3633 by FlowHeater-Team
Replied by FlowHeater-Team on topic Parameters
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

Did this answer your question? We would be grateful if you provide a brief comment as feedback. It may also help others who may have encountered a similar problem.
Last edit: 2 years 8 months ago by FlowHeater-Team.

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

More
2 years 8 months ago #3634 by JD Cox
Replied by JD Cox on topic Parameters
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.265 seconds

FlowHeater - The Data Specialist

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

Rechtliches

Support & Contact

Kontaktinformation

Telefon:0951 / 99339792 E-Mail:This email address is being protected from spambots. You need JavaScript enabled to view it.

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