Funding Example

Injector Script

The following tutorial was developed by Matt Heller using the mdEditor File Injector script he developed, which can be used to do bulk edits on your mdEditor files. This demo specifically walks through how to add a contact with the role of “administrator” to funding allocations.

A recording of this demo is available for viewing at: https://mmancusa.webex.com/mmancusa/ldr.php?RCID=b368e65eafffc4c076e9a4993f438b42

You will need:

  1. Access to some mdEditor files. Note: these must be mdEditor files, NOT the mdJSON files attached to the SB items.
  2. Python installed on your PC.
    • If you have ArcGIS installed, there is a good chance Python is installed.

Steps

1. Download script and other helpful files from GitHub.

  1. Go to https://github.com/mmheller/mdEditorFileInjector and download all the files.

  1. Unzip to any folder.

2. Gather some mdEditor files for the demo test.

  1. Create a folder named Demo somewhere convenient.

  1. Copy/paste 2-5 of YOUR mdEditor files into the Demo folder.

3. Build the string that will have the necessary arguments to run the script.

  1. Open any text editor (e.g., notepad) and enter the following letters with Dashes on separate lines (–C –D –F –f –T –O).

For reference, the final version will look like this. Follow the specific steps below to write each line.

  1. Enter the path to the Demo folder in line –C. Note: all files and files in subfolders will be processed by the script. No original files will be edited, copies will always be made.

  1. Enter “metadata|funding” in line –D. This is the location in the JSON that we’re telling the script to look for finding JSON text. Note: be sure to add double quotes for this argument.

  2. For line –F

  1. Copy/paste the path to the unzipped folder with all the injector script files.
  2. AND copy/paste the file name inject_FundingAdministrator.txt

Make sure to separate the path and filename with a back slash. This holds all the text we will inject.

  1. For line –f, do the same thing but with the file name find_FundingAdminstrator.txt. This holds all the text the script uses to find text to replace.

  2. Add False to the –T line. This indicates we’re not adding new contacts to the available contacts list.

  3. Add 6 to the –O line. This specifies the option for the more complex find/replace.

4. Edit the inject_FundingAdministrator.txt file with the Contact ID of your choice.

  1. Open mdEditor, clear the cache, and then import one of the mdEditor files from the demo folder.

  2. However you want to do it, copy the Contact ID of your choice.

  1. Open inject_FundingAdministrator.txt in a text editor and overwrite the Contact ID value in the file. Save and then close the file.

Note

The Contact ID you enter must be the same for all the mdEditor files you want to run through the processor (or are in the demo folder). If you have different Contact IDs to inject across different records, you must do these in separate iterations of the script with only the relevant mdEditor files for each contact ID. If you have different Contact IDs to add within the same record, you cannot use the script and must edit those records manually in mdEditor.

5. Open the find_FundingAdminstrator.txt file.

Make sure it says:

6. Inspect one or more of the mdEditor files in mdEditor.

  1. Go to Funding. Choose an allocation where match is not selected and click “More.” Then click “Edit” for the allocation. Scroll down and notice no entries under “Other Contacts.”

7. Run the script.

  1. Back in the text editor, add two blank lines in the beginning.

  1. Find the path to your python.exe and enter in the 1st line. Example: C:.exe

  2. Find the path to your .py injector script file and enter in the 2nd line. Note: this will be in the folder you downloaded and unzipped. Example: C:-master_v1.py

  1. Remove all the carriage returns and extra spaces, and save if desired. Note: if any of your file paths have spaces, make sure to enclose the full path/filename with double quotes.

  1. Open a DOS prompt.

  1. Copy/paste the text from your text editor into the command prompt to run.

8. Inspect the results.

  1. Open mdEditor and clear the cache.

  2. Click Import. Go to the demo folder and into the new folder created. Note: each time the process runs it will create a new folder and add new files to this folder.

  1. Select one of the new files to import.

  2. Go to Funding. Choose an allocation where match is not selected and click “More.” Then click “Edit” for the allocation. Scroll down and notice a new entry under “Other Contacts.”

Note: If it errors out, there’s a problem. Go to the demo folder and into the new folder created and do the following:

  1. Note the filename that is a problem
  2. Remove the file from the demo folder
  3. Delete the new folder and files created from the last run
  4. Rerun