Hello @pankaj727,
Thank you for reaching out the Docusign Community! We are happy to have you here and look forward to sharing as much knowledge as we can.
Can you please elaborate a little bit? Are you using Salesforce to generate/send documents? Are you using a combination of TableRow Tag (GEN) + Anchor Text Tags and trying to align the 2 so that each Merge Field would match the GEN row (record) it is called on?
We look forward to your update. Thank you!
Regards,
Melanie | Docusign Community Moderator
If this helped, feel free to click "Best Answer"!
Yes, In this scenario I am using APEX code to generate these anchor tags in sequence using Docusign (GEN) and then passing this document to Docusign (Envelope Template).
Hi @pankaj727,
Thank you for getting back to me. The default order is based on the way Salesforce returns the data. We use simple selects statement to retrieve the Merge Fields without any specific sorting and as this article states: ORDER BY | SOQL and SOSL Reference | Salesforce Developers
There’s no guarantee of the order of results unless you use an ORDER BY clause in a query, and based on others’ experience, the order of the records returned is not consistent. So it's not known the exact order with which records are returned when it comes to Merge Fields > Anchor Text Tags.
Hope it helps. If you found my response useful, please consider marking it as the 'Best Answer'
to assist other community members with similar questions.
Feel free to also Open a case in the Docusign Support Center to be assisted by the Salesforce Specialized Team.
Let us know if you have questions or need further assistance. We're here for you! 
Regards,
Melanie | Docusign Community Moderator
If this helped, feel free to click "Best Answer"!
Hello @pankaj727,
If my response helped solve your question, could you click the “Best Answer ✅” button below the post? That helps others in the Community find trusted answers faster.
Thanks for being part of the Docusign Community!
Regards,
Melanie | Docusign Community Moderator
Using ORDER BY in Apex is easy but How can we use ORDER BY in the context of Docusign Envelope Template so that we can decide the sorting order in Envelope? Can you provide an example of that.
Hello @pankaj727,
EFS (EFS = eSignature For Salesforce) and the DET (DET = Docusign Envelope Template) work differently from when using Apex. Since the EFS process relies on the eSignature process and Docusign settings, SF commands such as ORDER BY do not apply. If you would like to use anchor text or EFS to apply the fields, you cannot determine the order the related list fields are applied, because you cannot set this. However, there is a workaround using a server template and placing fields where you can determine the order. The process would have to be created something similar to the following:
Create Docusign Server Template:
- Log in to Docusign and go to My Preferences > Template matching.
- Set the sensitivity to 80% and enable Match on page level.
- Choose the have Manually add the template matching to make it easier for testing.
- Tip: Once you test and confirm the process works, you should also enable Apply template automatically under the Template Matching settings.
- Create the server template by going to the Templates tab, locating the desired envelope template, and copying it.
- Rename the template and upload the Gen template Word file with the Gen anchor statements.
- Important: Ensure the documents added to the Gen template are the same documents uploaded to the server template. The document order does not matter, but the number of pages must match.
- Select Next, add the desired eSignature Conditional Logic fields, and select Save and Close.
- Test the template before deploying it.
Result
This workaround provides the following user experience:
- The user goes to the Salesforce record and selects the Docusign Gen button.
- Docusign Gen generates the document following the template configuration, and the user selects Send with Docusign.
- The envelope template configuration applies to the envelope (i.e. Recipients, Writeback Settings, etc.).
- The user goes to the Prepare and Send section and selects the tab or Next button.
- They are brought into the tagging screen where the server template settings apply the conditional logic/eSignature fields to the envelope documents via the template matching settings.
- The user reviews everything and sends the envelope.
I hope I answered your question. Thank you!
Regards,
Melanie | Docusign Community Moderator