BookmarkSubscribeRSS Feed
ShenQicheng
Obsidian | Level 7

Hi,

I am creating an EG custom task with more than one input data and [InputRequired] attribute being set to [InputResourceType.None].

In task’s [Show] override method I use the [Consumer.ShowInputDataSelector] to require all input data before showing task form.

There is a [TaskSelectedDataControl] control on the task form that user can use it to filter the dataset.

Here is the problem:

  1. Create a new task on a new EG project.
  2. Select a dataset for input data in the pop-up dialog.
  3. Click the [Edit] button of [TaskSelectedDataControl] control on the task form.
  4. Click the [OK] button of the filter setting dialog.

      

An error occurred say “Can not select a data source. Reason: Index out of range.”.

   

If I ignore the above error and save the task, (the selected input data comes out to the project flow at this time) and open it again and do same processes as above, no error occurs.

   

Is there any way that I can resolve this problem?

Is there any must thing that I missed after calling ShowInputDataSelector?

   

You can reproduce this by making a few changes on SASPress.Examples.RunningTotals:

  1. Task attribute: [InputRequired(InputResourceType.None)]
  2. At beginning of public override ShowResult Show(System.Windows.Forms.IWin32Window Owner) insert following code  

            var cookie = string.Empty;

            var selectedDatasets = Consumer.ShowInputDataSelector(

                null, DataSelectionMode.ReadOnlySingleInput, ServerAccessMode.AnyServer,

                "", "SASHELP", string.Empty, ref cookie) as ISASTaskData2[];

            Consumer.ClearInputData();

            Consumer.AddInputData(selectedDatasets[0]);   


Thanks in advance.

2 REPLIES 2
ChrisHemedinger
Community Manager

Hi,

Be sure to check for null on the selectedDatasets variable before you try to reference it.  If you click Cancel on the data selector, the return will be null. You should then call ClearInputData and AddInputData only if the selectedDatasets != null.

Also, ShowInputDataSelector returns an array of ISASTaskData[], not ISASTaskData2[].  You should probably not try to cast this to ISASTaskData2   The returned object in the array will support ISASTaskData and ISASTaskData2, but the way the interfaces are designed, I would not cast those to other types unless you need the specific ISASTaskData2 methods/properties.

Chris

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
ShenQicheng
Obsidian | Level 7

Hi,

Thanks for you answer, but it still not make my problem solved.

Sorry for the incomplete sample code I posted.

Yes, I do confirm the selectedDatasets variable being not null before doing anything further in my real code.

The reason that I cast the return type of ShowInputDataSelector methods to ISASTaskData2[] is for convenience that I will need this later:

1. Get columns of the dataset by using GetColumns() methods of SasData class whose constructor needs a SASTaskData2 type parameter.

2. Set the TaskData property of TaskSelectedDataControl.

I can change both of them to do cast right at it is being used , if it helps, just like the SASPress.Examples.RunningTotals sample shows.

My prolem is, I call Consumer.ShowInputDataSelector to select a data and set it to TaskSelectedDataControl's TaskData property, then in the TaskSelectedDataControl I do nothing but click the OK button, the error message box pops up.

This only occures when I create the task on a new project.

Thanks

Shen

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 861 views
  • 0 likes
  • 2 in conversation