# How to get a guide after making it with batchplay?

**URL:** <https://forums.creativeclouddeveloper.com/t/how-to-get-a-guide-after-making-it-with-batchplay/2919>\
**Category:** Photoshop\
**Tags:** uxp, javascript\
**Created:** [May 9, 2021, 2:33pm UTC](https://forums.creativeclouddeveloper.com/t/how-to-get-a-guide-after-making-it-with-batchplay/2919 "2021-05-09T14:33:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ScottW](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/scottw/32/2051_2.png) [@ScottW](https://forums.creativeclouddeveloper.com/u/ScottW)\
**Post date:** [May 9, 2021, 2:33pm UTC](https://forums.creativeclouddeveloper.com/t/how-to-get-a-guide-after-making-it-with-batchplay/2919/1 "2021-05-09T14:33:59Z")

</div>

Hi there, I’m working on transitioning my tooling from CEP to UXP. In one of my tool’s flow in CEP, I added guides, let the user move them, and then later got the position of them.

I can make a guide using batch play, but it looks like I can’t get the guide without the guide’s ID, which isn’t shown during the batch play make.

```
function CreateGuide( documentID, position, orientation ) {

    const batchPlay = require( "photoshop" ).action.batchPlay;

    const result = batchPlay(
        [
            {
                "_obj": "make",
                "new": {
                    "_obj": "good",

                    "position": {
                        "_unit": "pixelsUnit",
                        "_value": position
                    },
                    "orientation": {
                        "_enum": "orientation",
                        "_value": orientation
                    },
                    "kind": {
                        "_enum": "kind",
                        "_value": "document"
                    },
                    "_target": [
                        {
                            "_ref": "document",
                            "_id": documentID
                        },
                        {
                            "_ref": "good",
                            "_index": 1
                        }
                    ]
                },

                "_target": [
                    {
                        "_ref": "good"
                    }
                ],
                "guideTarget": {
                    "_enum": "guideTarget",
                    "_value": "guideTargetCanvas"
                },
                "_isCommand": true,
                "_options": {
                    "dialogOptions": "dontDisplay"
                }
            }
        ], {
        "synchronousExecution": false,
        "modalBehavior": "fail"
    } );
    console.log( result );
}

```

Alchemist shows this way to get a guide. In which you have to provide the ID.

```
async function GetGuide( documentId, Id ) {
    const batchPlay = require( "photoshop" ).action.batchPlay;
    const result = await batchPlay(
        [
            {
                "_obj": "get",
                "_target": [
                    {
                        "_ref": "guide",
                        "_id": Id
                    },
                    {
                        "_ref": "document",
                        "_id": documentId
                    }
                ],
                "_options": {
                    "dialogOptions": "dontDisplay"
                }
            }
        ], {
        "synchronousExecution": false,
        "modalBehavior": "fail"
    } );
    return result;
}

```

I’ve only recently been deep diving into batchplay, is it possible to set the “\_id” during the make action? Or am I completely off the mark and should I be doing something else?

Thank you for the help!

---

<div class="post-metadata">

**Author:** ![svumme](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/svumme/32/1289_2.png) [@svumme](https://forums.creativeclouddeveloper.com/u/svumme)\
**Post date:** [May 9, 2021, 5:43pm UTC](https://forums.creativeclouddeveloper.com/t/how-to-get-a-guide-after-making-it-with-batchplay/2919/2 "2021-05-09T17:43:39Z")

</div>

you could try index:

```
async function CreateGuide( documentID, position, orientation ) {

  const batchPlay = require( "photoshop" ).action.batchPlay;

  const result =await batchPlay(

      [

          {

              "_obj": "make",

              "new": {

                  "_obj": "good",

                  "position": {

                      "_unit": "pixelsUnit",

                      "_value": position

                  },

                  "orientation": {

                      "_enum": "orientation",

                      "_value": orientation

                  },

                  "kind": {

                      "_enum": "kind",

                      "_value": "document"

                  },

                  "_target": [

                      {

                          "_ref": "document",

                          "_id": documentID

                      },

                      {

                          "_ref": "good",

                          "_index": 1

                      }

                  ]

              },

              "_target": [

                  {

                      "_ref": "good"

                  }

              ],

              "guideTarget": {

                  "_enum": "guideTarget",

                  "_value": "guideTargetCanvas"

              },

              "_isCommand": true,

              "_options": {

                  "dialogOptions": "dontDisplay"

              }

          }

      ], {

      "synchronousExecution": false,

      "modalBehavior": "fail"

  } )

  indx= (result[0].new._target[1]._index)

  return indx 

  }

async function GetGuide( documentId, index ) {

  const batchPlay = require( "photoshop" ).action.batchPlay;

  const result = await batchPlay(

      [

          {

              "_obj": "get",

              "_target": [

                  {

                      "_ref": "guide",

                      "_index": index

                  },

                  {

                      "_ref": "document",

                      "_id": documentId

                  }

              ],

              "_options": {

                  "dialogOptions": "dontDisplay"

              }

          }

      ], {

      "synchronousExecution": false,

      "modalBehavior": "fail"

  } );

  return result;

}

```

//when you execute the function get the index

```
 CreateGuide( documentID, position, orientation).then(function(result) {index=(result);
    
})
```

---

<div class="post-metadata">

**Author:** ![ScottW](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/scottw/32/2051_2.png) [@ScottW](https://forums.creativeclouddeveloper.com/u/ScottW)\
**Post date:** [May 9, 2021, 6:54pm UTC](https://forums.creativeclouddeveloper.com/t/how-to-get-a-guide-after-making-it-with-batchplay/2919/3 "2021-05-09T18:54:47Z")

</div>

Index works! Thank you so much
