Parameter Magic

Related products: Software Factory

When creating a control procedure, it is useful to have an overview of all parameters within the template.

I usually go through the following steps:

  1. Create a object (Task, Subroutine, Function etc..) with parameters
     
  2. Create a Control Procedure and Assign the ‘New’ template to the object
     
     

     

  3. Generate the definiton, copy-paste all parameters to the template and add following the text at the end of each parameter: ‘-- [empty_line_on_generate]’
     

    Code:

    -- PARAMETERS FOR DEVELOPMENT           -- [empty_line_on_generate] 
    DECLARE @id AS id -- [empty_line_on_generate]
    DECLARE @parameter_01 AS text_10 -- [empty_line_on_generate]
    DECLARE @parameter_02 AS text_1000 -- [empty_line_on_generate]
    DECLARE @parameter_03 AS date_no_time -- [empty_line_on_generate]
    DECLARE @parameter_04 AS int -- [empty_line_on_generate]
    DECLARE @parameter_05 AS amount -- [empty_line_on_generate]
    DECLARE @parameter_06 AS amount -- [empty_line_on_generate]
    DECLARE @parameter_07 AS percentage -- [empty_line_on_generate]
    DECLARE @parameter_09 AS country_id -- [empty_line_on_generate]
    DECLARE @parameter_10 AS text_255 -- [empty_line_on_generate]


    Generate the parameters, empty the value and switch the ‘no_line_when_empty’ option to ON
     

     

  4.  

As a result, you always have access to all parameters, which you can give a value to test the code during development.

Like this:

-- PARAMETERS FOR DEVELOPMENT                    -- [empty_line_on_generate]
DECLARE @id AS id = '1234' -- [empty_line_on_generate]
DECLARE @parameter_01 AS text_10 = 'ABC' -- [empty_line_on_generate]
DECLARE @parameter_02 AS text_1000 = 'ZZZ' -- [empty_line_on_generate]
DECLARE @parameter_03 AS date_no_time = NULL -- [empty_line_on_generate]
DECLARE @parameter_04 AS int = NULL -- [empty_line_on_generate]
DECLARE @parameter_05 AS amount = NULL -- [empty_line_on_generate]
DECLARE @parameter_06 AS amount = NULL -- [empty_line_on_generate]
DECLARE @parameter_07 AS percentage = NULL -- [empty_line_on_generate]
DECLARE @parameter_09 AS country_id = 'NL' -- [empty_line_on_generate]
DECLARE @parameter_10 AS text_255 = 'XXXX' -- [empty_line_on_generate]

INSERT INTO .... ETC..

And you will not have errors when executing the code.


Idea for improvement in SF: Add some code to the ‘Assign’ button to automate step 3 and 4

 

Great way of getting the parameters to the template.

Difficulty could be when assigning the template to multiple program objects. In that case the intersection of all parameters that appear in the various program objects could be a solution. Also makes it easier to focus only on those parameters and prevent making a mistake by using a parameter that is not part of one of the program objects.


An extra could be that when the minimal set of necessary parameters is included in the template, it could be possible to only show those program objects for which these parameters apply. Making it impossible to select a program object that doesn't supply these parameters.

Furthermore it could be possible to signal the impact of changing the parameters of an object (e.g. by adding, removing, or renaming a column) making the use of a certain control procedure (im)possible.


Ideally, a pop up, asking 'Add parameters for development (Y/N)’, appears when the 'Assign’ button is used to create the New template.

But for me, the parameters could always be created, because most of the time it helps and if not, you can simply delete them from the template.

Another idea is to have a task in the template form, to remove all rows in the header which are like 'DECLARE%-- [empty_line_on_generate]’ and recreate the parameter lines again, based on last model definition.

 

 


Actually, just a few lines of code need to be added to ‘task template assignment add’ to achieve this, I consider to just do this myself as a test.


Hey Harm,

Do you know about the open and import feature? When you use this, you will have the complete procedure and all the parameters, so you have auto-complete. You change the generated code and then import it into the template. 

Would this work around your wish, or am I missing something?

Of course, this works especially for simple templates and a little less well for the complex situations, that Roy describes where a template is used multiple times.


Updated idea statusClosedMerged
Idea merged into:

All the votes from this idea have been transferred.