Export Rules from IDN and clean formatted to read again

Since the IAD admin console it gone what is a the best way to export Rules to review them from my system.

Also does anyone have any good tips on how reformat the script for that rule so i can read it as it needs.

The api in beta seams to be gone as well

1 Like

Hi,

To reformat you can use notepad++. Select All

  1. Ctl+F
    2.Select Replace tab, then in find what add “\n”
    3.Replace with “|”
  2. Make Sure Search mode selected as normal
  3. Click on Replace all

Once click on replace all fellow the below steps:

  1. In Find what add “|”
  2. In Replace with add \n
  3. Make sure Search Mode is Extended
2 Likes

Hi Andy,

If you are fine to use the online URL, then you can use the below link to add the code and then click on unescape json button, it shall give you the formatted code with one click.

You can then copy it notepad ,vscode or any other preferred tool and do the necessary modification. Once the modifications are done, you can again take the code and paste it in the above link and click on the escape json, this shall give you the code which you can directly update using update connector rule API or submit to expert team if it is a cloud rule.

If you are not looking for online resources, then I personally prefer vscode as it also allows us to escape and unescape json with 3-4 steps. Please let me know if you will need the information, i can share it then.

I hope this helps.

Regards
Vikas.

1 Like

Hi @vguleria ,

Can you please share the detailed information step by step to escape the characters using notepad++ or Visual studio. we don’t have access to use the online link.

Thanks
Prathyusha.

If you have the VS code plugin from Yannick you can extract connector rules with ease

2 Likes

did not work Ivan as it should and why i look to other options

Hi @ipobeidi ,

Thanks for your response. Can you please help me to convert the xml rule to json format rule by adding escape character, which we will use in postman to commit. Can you please let me know if any short cut is there using note pad++.

Thanks,
Prathyusha.

Hi @sivakrishna_1993

you can do that all in one replacement step (search mode: Extended) and it will stop accidental replacement of | characters you may have (if they exist)

Find \\n
Replace \n

I would also do the same with tab characters

Find \\t
Replace \t

1 Like

Sure, what type of rule we are talking about?

@Adel0623 , is a cloud rule of a connector rule?

we are working on web service connector application ,for this we have developed on before operation rule, we need to push that rule into cloud, where we have to follow proper format right, that we are not able to convert it. Ex : removing new line with \n and removing double quote with ".

1 Like

Use this tool to escape , after scap you can use this template to push it to the cloud :

{
    "name": "s",
    "type": "WebServiceBeforeOperationRule",
    "signature": {
        "input": [
            {
                "name": "application",
                "description": "The application whose data file is being processed.",
                "type": null
            },
            {
                "name": "requestEndPoint",
                "description": "The current request information contain header, body, context url, method type, response attribute map,\n          successful response code\n        ",
                "type": null
            },
            {
                "name": "oldResponseMap",
                "description": "earlier response object ",
                "type": null
            },
            {
                "name": "restClient",
                "description": "REST Client Object",
                "type": null
            }
        ],
        "output": {
            "name": "EndPoint",
            "description": "Updated EndPoint Object",
            "type": null
        }
    },
    "sourceCode": {
        "version": "1.0",
        "script": "ESCAPEDD STRING"
    },
    "attributes": {
        "sourceVersion": "1.0"
    },
    "description": "This rule is used by the  Web Services connector before performing any operation like testconnection, aggregation, etc."
}

Then you just need to use postaman to push it to cloud.

1 Like

Hi @ipobeidi ,

Thanks for trying to help us, but we are not able to access that link, because we don’t have permission to access the site. is there any alternative way we can do it using notepad++.

Thanks,
Prathyusha

Hi @prathyusha730 ,

I can understand that some organization does not allow to use online URL. For escaping un-escaping the json, below are the steps that i generally perform via VsCode.

  1. Open a new file in vs code using key (control+n) .
  2. select the language type java or powershell as per your need. I believe for web service connector you will be using java most probably.

  1. paste your code from postman into this file.

  2. paste the connector rule into this file.

Now here, we need to mainly replace the below keyword 
- \n with newline  
-  \" with double quotes " .
- \t with normal spaces (1 or multiple depending on your need) or tab spaces

  1. To replace the \n with newline, press control+H key. In the first field enter \n. And in the replacing character field type shift+enter. then click on replace all button.
    This should replace all the newline characters with new line.

image

  1. Similarly, to replace the double quotes, press control+H key. In the first field enter \" and in the replacing character field type ". Then click
    on replace all characters button.

  2. for \t, again press control+H keys. In main sheet, select any empty line and hit tab and then copy the text of this tab. In the first field enter \t and then in the replacing character field, enter control+v and then click on replace all characters button on vs code.

This will be your unescaped json version and then you can make the changes to the code.

Once the changes are done, again open a new file (control +n ) and follow the below steps to convert the code into escaped json format.

  1. Similarly, to replace the double quotes, press control+H keys. In the first field enter " and in the replacing character field type \". Then click
    on replace all character button.

  2. To replace tab spaces with \t, again enter tab key in your file and copy the text of tab key. Then press control+H, in find character, control+v and in replacing character field add \t and then click on replace all characters button.

  3. To replace the all newlines with \n, press control+H key. In the first field enter shift+enter key. And in the replacing character field type \n. then click on replace all button.
    This should replace all the new line with newline characters \n.

The steps may look long but as requested these are the detailed steps and i am sure if you try it couple of times, it will hardly take you a minute to perform them.

There are also some cool tricks in vs code where you can select a character and then find all occurances immediately and then replace them without having to
press control+h again and again but i would suggest you to please explore them in vs code.

I hope this helps.

Happy coding.

Regards
Vikas.

1 Like

For VSCode users - please have a look at the Hediet Power Tools extension: Hediet Power Tools - Visual Studio Marketplace
It has a JSON escape assistance which allows you to directly edit the json embedded source code of the rule with a right click.

1 Like

Thank you @oliver_goebel2 for sharing. I have not tried it but believe this is even better solution. I will definitely try it.

VSCode has now the script editor integrated in the new version.
A right click on the rule will give you a “Edit Script” option.
Does even have syntax highlighting :heart_eyes:

1 Like