Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter debargh

    (@debargh)

    Hi George,

    I was using the alias.attribute but it wasn’t working so I ended up sending the annotationID to a product attribute in CRM using a workflow and now can use the annotationId directly within the view. This final help with the filter drop down will be great!

    If I’m creating a dropdown like below then on select I want to only show the products (attributes) based on the selected option. For ex- I’ve a product attribute name ‘market’ value = coffee in CRM. After the view loads in this page, how do I compare it with the selection below, then show rest of the attributes for that product using something like {% if selected == coffee %} equals to market attribute from the view within the for loop.

    [msdyncrm_twig]
    
    <label for="market-select"><h3> Select a Market:</h3></label>
    <select id="market-select">
        <option value="">--Please choose an option--</option>
        <option value="berries">Berries</option>
        <option value="coffee">Coffee</option>
     </select>
    
    {% set viewSettings = { entity: "product", name: "Products Posted on Oxbo Website" } %}
    {% view entity=viewSettings.entity name=viewSettings.name cache="PT2H" %}
    
    <div class="row">
      {% for recordId, record in entityview.rows %}
               <h4 class="card-title"><a href="{{ entityUrl( 'product', recordId ) }}">{{ record['name'].value }} </a> </h4>
      {% endfor %}
    </div>
    {% endview %}
    [/msdyncrm_twig]
    Thread Starter debargh

    (@debargh)

    Hi George,

    If I am linking Product to Annotation with fetch xml as below, I can get the product attributes as product.name etc but product.annotation is not giving me the annotationid, what should be the syntax for it?

    [msdyncrm_twig]
    
    {% fetchxml collection="product" cache="PT30M" %}
    
    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
      <entity name="product">
        <attribute name="oxbo_make" />
        <attribute name="name" />
        <attribute name="productid" />
        <attribute name="oxbo_webaskingprice" />
        <attribute name="entityimageid" /> 
        <order attribute="oxbo_make" descending="false" />
        <filter type="and">
          <condition attribute="statecode" operator="eq" value="0" />
          <condition attribute="oxbo_displayinweb" operator="eq" value="1" />
          <condition attribute="oxbo_sold" operator="eq" value="0" />
          <condition attribute="quantityonhand" operator="gt" value="0" />
          
        </filter>
        <link-entity name="annotation" from="objectid" to="productid" alias="aa">
          <attribute name="annotationid" /> 
          <filter type="and">
            <condition attribute="objecttypecode" operator="eq" value="1024" />
          </filter>
        </link-entity>
      </entity>
    </fetch>
    
    {% endfetchxml %}
    
    <div class="row">
      {% for product in product.results.entities %}
      <div class="col-sm-6 col-md-4">
        <div class="card">
    
           <div class="card-block">
            
             <li><h4 class="card-title"><a href="{{ entityUrl( 'product', product.productid ) }}">{{ product.name }} </a></li>     
             <li>{{ product.oxbo_make }}</li> 
                                                              
             <li>Buy for {{ product.oxbo_webaskingprice }}</li>
             
             <li><a href="{{ attachmentUrl( annotationid ) }}">Save Report </a></li>
             <li>{{ product.annotationid }}</li>    
                   
          </div>
        </div>
      </div>
      {% endfor %}
    </div>
    [/msdyncrm_twig]
    Thread Starter debargh

    (@debargh)

    Hi George,

    I understand <a href="{{ attachmentUrl( annotationid ) }}">Save </a> is going to get me the attachment. My question is how do I get the annotationid, from a product view or a product form. AnnotationId is not a part of Product entity in CRM, due to 1:N mapping there might be N annotationid’s for a product. Below is my code.

    First is a Product View, on clicking the ‘name’ in this below code, I am opening a Product Detail form from CRM, so where do I get the annotationid from this two page is where I’m having difficulty understanding?

    Product page

    [msdyncrm_twig]
    {% set viewSettings = { entity: "product", name: "Products Posted on Oxbo Website" } %}
    {% view entity=viewSettings.entity name=viewSettings.name cache="PT2H" %}
    
    <div class="row">
      {% for recordId, record in entityview.rows %}
      <div class="col-sm-6 col-md-4">
        <div class="card">
    
           <div class="card-block">
            <h4 class="card-title"><a href="{{ entityUrl( 'product', recordId ) }}">{{ record['name'].value }} </a> <small class="text-muted"> {{ record['product.productid'].formatted_value }}</small></h4>   
             {{ record['oxbo_webdescription'].formatted_value|wpautop|raw }}
                                                                    
            <a href="#" class="btn btn-primary">Buy for {{ record['oxbo_webaskingprice'].formatted_value }}</a>
            
          </div>
        </div>
      </div>
      {% endfor %}
    </div>
    {% endview %}
    [/msdyncrm_twig]

    The Product Detail page is:

    <style type="text/css">
    .form-horizontal .control-label {
      text-align: left;
      font-weight: bold;
    }
    </style>
    
    [msdyncrm_field field="entityimage"]
    <h2>[msdyncrm_field field="name"]</h2>
    
    [msdyncrm_twig]
    
    [/msdyncrm_twig]
    
    [msdyncrm_form entity_name='product' form_name='Product Detail' mode='readonly' parameter_name='id' enable_layout='true']

    I took Steak Knives example to create the above two pages. Using <a href="{{ attachmentUrl( annotationid ) }}">Save </a> is giving me blank page with object not found, which makes sense because it is not getting the annotationid, if I directly type the annotaionid GUID on the url, the file attachment is getting downloaded. So how do I get the annotationid for each products and which page from the above 2 pages should I use the attachmentUrl function?

    Thanks for your help!

    Thread Starter debargh

    (@debargh)

    Hi George,

    recordId is the productid of a product in a view, from a product view on click it is opening a product detail page for that product which is a CRM product form. The below code is what calling the form.

    I’m using the exact same line but it is not showing the attachment. Also how the Product form below is supposed to get the AnnotationId from Annotation entity in CRM, AnnotationId is an attribute of Annotation entity, objectid attribute in annotation is the productid which is the only link for that attachment to a product. AnnotationId is the unique identifier of the attachment itself. Thanks!

    [msdyncrm_twig]
    
    <a href="/wp-admin/admin-ajax.php?action=msdyncrm_attachment&id={{ AnnotationId }}"> </a> 
    
    [/msdyncrm_twig]
    
    [msdyncrm_form entity_name='product' form_name='Product Detail' mode='readonly' parameter_name='id' enable_layout='true']
    • This reply was modified 4 years, 4 months ago by debargh.
    • This reply was modified 4 years, 4 months ago by debargh.
    Thread Starter debargh

    (@debargh)

    Hi George,

    I’m using the below code on the product page like you said but it is not showing the entityimage.

    <i m g s r c=”/wp-admin/admin-ajax.php?action=msdyncrm_image&id={{ recordId }}”>

    or do you mean to use the below code on the product detail page which is reading from a CRM product form?

    <i m g s r c=”/wp-admin/admin-ajax.php?action=msdyncrm_image&id={{ AnnotationId }}”>

    Also if I have a pdf attachment instead of a picture inside attachment (Notes area) then what would be the url code for it?

    Since [msdyncrm_field field=”entityimage”] works fine so I can atleast get the entityimage on the product detail page, I just need to get the <img src….. url to work correctly to get the image on the product page and another to get a pdf attachment on the detail page.

    Much thanks!

    Debargh

    Thread Starter debargh

    (@debargh)

    Sorry about the images, posting the code again

    <i m g s r c=”/wp-admin/admin-ajax.php?action=msdyncrm_productimage&id={{ recordId }}” style=”float:left;margin-right:1rem;”> //Does not work

    [msdyncrm_field field=”entityimage”] //works fine
    <h2>[msdyncrm_field field=”name”]</h2> //works fine

    <p>< i m g s r c=”data:image/jpeg;base64,{{currentrecord.entityimage}}”></p> //Does not work

    <i m g s r c=”/wp-admin/admin-ajax.php?action=msdyncrm_attachment&id={{ AnnotationId }}”> //Does not work

    Thread Starter debargh

    (@debargh)

    Hi George,

    Thanks for the reply!

    I am following the Steak/Knives example and that is where some of the coding is not working for me. I have two pages Product(calls a product view in CRM) and Product Detail(calls a form for product in CRM).

    On the product page the below line is not pulling in the entityimage, changing it to msdyncrm_entityimage&id = {{ recordId }} is also not working. Displaying other fields as record[”] is not an issue and works fine.

    One the product detail page

    [msdyncrm_field field=”entityimage”] shows the entity image

    But below {{currentrecord.entityimage}} is pulling nothing and this is where I’m mainly confused about pulling in the attachments, the attachments are saved in AnnotationBase in CRM, msdyncrm_attachment&id={{ AnnotationId }} OR
    msdyncrm_annotationbase&id={{ AnnotationId }} is not working.

    Inside the annotationbase table annotationid is the unique id for attachments and objectid is the productid. Both the pages have entity binding as product, parameter name is ID, query string parameter value is id and empty parameter behavior is ignore, checked Set default for views.

    [msdyncrm_field field=”entityimage”]
    <h2>[msdyncrm_field field=”name”]</h2>
    [msdyncrm_twig]
    <p></p>

    [/msdyncrm_twig]
    [msdyncrm_form entity_name=’product’ form_name=’Product Detail’ mode=’readonly’ parameter_name=’id’ enable_layout=’true’]

Viewing 7 replies - 1 through 7 (of 7 total)