Body: <p>I've run into a dead end when trying to create custom URL's for a product type in Commerce 2. I want to create the URL from a custom field -- a Commerce Product field to be exact. This product does not have variants.</p>
  
  <p>I've referenced <a href="https://craftcms.stackexchange.com/questions/22497/get-the-category-into-the-url-of-the-product-page">this question here</a>, but the example did not work for me.</p>
  
  <p>Here is what I've tried with no success: <code>{relatedImage.first().id}</code>, <code>{relatedImage[0].id}</code>, <code>{object.relatedImage.first().id}</code>.</p>
  
  <p>When the Craft task manager tries to rerun these products, it just errors out (Failed). And I'm not sure where to find task manager error logs to see if I can get any information from them.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-08-06T18:31:51.350Z
Comments.Text: The underlying error for the failed job will be in your project's `craft/storage/logs` or `storage/logs` folder depending on how you have it setup.
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-08-07T13:59:03.073Z
Comments.Text: "Could not generate a unique URI based on the URI format". The URI format is: `{relatedImage.first().id}`. It's looking for the id of a selected commerce product. Is that not possible?
Comments.UserDisplayName: John Johnson
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-08-07T23:53:03.920Z
Comments.Text: Assuming `relatedImage` is the Commerce Product field, is it inside of Matrix or SuperTable or the like? Or is it at the root?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-08-08T16:08:42.957Z
Comments.Text: It's at the root.
Comments.UserDisplayName: John Johnson
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-08-08T22:58:11.097Z
Comments.Text: Just did a test of this locally on the latest Commerce 2 beta. Created a Commerce Products field, added it to the Product Type field layout using `{relatedImage.first().id}` as the URI Format, created a new Product, selected a related Product with an ID of 10, then the new Product's resulting URI is the expected `site.com/10`
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-08-13T17:20:43.677Z
Comments.Text: Just to confirm: I have two product types: Images, Recipes. When adding a Recipe, that's where the relatedImage field is present. This field allows me to select an Image-type product. Upon doing so, I want to use that Image's ID as the slug in the URL of the recipe. `{relatedImage.first().id}` does not appear to be working on my end, despite the good results you have found, Brad.
Comments.UserDisplayName: John Johnson
Tags: <plugin-craftcommerce2>
Title: Custom Commerce product type URL from custom field
ThreadText: # Custom Commerce product type URL from custom field
  
  (Asked by: username_0 on 2018-08-06)
  
  I've run into a dead end when trying to create custom URL's for a product type in Commerce 2. I want to create the URL from a custom field -- a Commerce Product field to be exact. This product does not have variants.
  
  I've referenced [this question here](https://craftcms.stackexchange.com/questions/22497/get-the-category-into-the-url-of-the-product-page), but the example did not work for me.
  
  Here is what I've tried with no success: `{relatedImage.first().id}`, `{relatedImage[0].id}`, `{object.relatedImage.first().id}`.
  
  When the Craft task manager tries to rerun these products, it just errors out (Failed). And I'm not sure where to find task manager error logs to see if I can get any information from them.
  
  **Tags:** plugin-craftcommerce2
  
  > **Comments:**
  > **username_1**: The underlying error for the failed job will be in your project's `craft/storage/logs` or `storage/logs` folder depending on how you have it setup.  
  > **username_0**: "Could not generate a unique URI based on the URI format". The URI format is: `{relatedImage.first().id}`. It's looking for the id of a selected commerce product. Is that not possible?  
  > **username_1**: Assuming `relatedImage` is the Commerce Product field, is it inside of Matrix or SuperTable or the like? Or is it at the root?  
  > **username_0**: It's at the root.  
  > **username_1**: Just did a test of this locally on the latest Commerce 2 beta. Created a Commerce Products field, added it to the Product Type field layout using `{relatedImage.first().id}` as the URI Format, created a new Product, selected a related Product with an ID of 10, then the new Product's resulting URI is the expected `site.com/10`  
  > **username_0**: Just to confirm: I have two product types: Images, Recipes. When adding a Recipe, that's where the relatedImage field is present. This field allows me to select an Image-type product. Upon doing so, I want to use that Image's ID as the slug in the URL of the recipe. `{relatedImage.first().id}` does not appear to be working on my end, despite the good results you have found, username_1.  
  
  ---
  
  ## 0 answers
  
  