1. Home
  2. Knowledge Base
  3. Validating via a Java External Object Source Code

Validating via a Java External Object Source Code

mrc recommends using the Workflow Designer to validate user input going forward.

Source Code

package MRCWORKLIB;

public class Validate
{
    public void valid_fields(String[] args)
    {
        String strdatex = args[1].replaceAll(",", "");
        String enddatex = args[2].replaceAll(",", "");
        int strdate = Integer.parseInt(strdatex);
        int enddate= Integer.parseInt(enddatex);

        if ((strdatex.compareTo("0") == 0 ) && (enddatex.compareTo("0") == 0 ))
            {
            args[0] = "You have not entered any dates";
            return;
            }

        else if (strdatex.compareTo("0") == 0)
            {
            args[0] ="You must enter a starting date";
            return;
            }

        else if (enddatex.compareTo("0") == 0)
            {
            args[0] = "You must enter an end date";
            return;
            }
        else if(strdate > enddate)
            {
            args[0] = "Starting Date is greater than End Date";
            return;
            }
        else return;
    }
}

Updated on June 20, 2023

Was this article helpful?

Need Support?
Can’t find the answer you’re looking for? Don’t worry we’re here to help!
Contact Support