Forum Replies Created

Viewing 15 replies - 1 through 15 (of 15 total)
  • Jon Brain

    (@brainjonbrain)

    Thanks. This helped me.

    Thread Starter Jon Brain

    (@brainjonbrain)

    Yes – that fixed it. Thank you!

    Strange – because I had the CF7 integration configured, I wouldn’t have thought I needed the custom one too.

    Thanks again for your help!

    Thread Starter Jon Brain

    (@brainjonbrain)

    In the end I abandoned using Dropzone because the project ran out of time/money. I may come back to it at a later date. I suspect the point @mosche makes about user roles (and especially how they use AJAX) is on the money – and if I do come back to Dropzone, this’ll be my first stop.

    Thread Starter Jon Brain

    (@brainjonbrain)

    The problem was related to the user capabilities. User needed to be an Editor in order for the dropzone to work correctly.

    Thanks,
    Jon

    Thread Starter Jon Brain

    (@brainjonbrain)

    OK, success!

    I fathomed what I was doing wrong with the fetchxml construct, and can confirm my custom function now works. Using [msdyncrm_twig] instead of the deprecated [msdyncrm_inline] shortcode was the answer all along.

    Many thanks for your time and assistance!

    Jon

    Thread Starter Jon Brain

    (@brainjonbrain)

    The problem I have replicating the query using [msdyncrm_twig], is that I can’t get the fetchxml command to work.

    In [msdyncrm_inline] I could use {% block fetchxml %}, but with [msdyncrm_twig] I seem to need to use {% fetchxml %}. However, the {% fetchxml %} command appears to need a “collection” attribute, and I don’t have one – I just want to query all of my data. How do I do that? The docs are very light in this area.

    Thanks,
    Jon

    Thread Starter Jon Brain

    (@brainjonbrain)

    I’ll post that snippet again:

    <?php echo do_shortcode("[msdyncrm_inline]
    	{% block fetchxml %}
    	<fetch distinct='false' mapping='logical' output-format='xml-platform' version='1.0'>
    		<entity name='new_building'>
    			<attribute name='new_buildingid'/>
    			<attribute name='new_name'/>
    			<attribute name='new_providerid'/>
    			<attribute name='new_address1_line1'/>
    			<attribute name='new_address1_line2'/>
    			<attribute name='new_address1_line3'/>
    			<attribute name='new_address1_city'/>
    			<attribute name='new_address1_stateorprovince'/>
    			<attribute name='new_address1_postalcode'/>
    			<attribute name='new_lowersize'/>
    			<attribute name='new_uppersize'/>
    			<attribute name='new_costlower'/>
    			<attribute name='new_costhigher'/>
    			<attribute name='new_latitude' />
    			<attribute name='new_longitude' />
    			<attribute name='new_managedofficespace'/>
    			<attribute name='new_servicedoffice'/>
    			<attribute name='new_coworkingspace'/>
    			<attribute name='new_virtualoffices'/>
    			<attribute name='new_leasedoffice'/>
    			<attribute name='new_buildingdescription'/>
    			<attribute name='new_locationdescription'/>
    			<attribute name='new_nearesttube'/>
    			<link-entity name='po_powerphoto' from='po_oid' to='new_buildingid' link-type='outer' alias='pp'>
    				<attribute name='po_powerphotoid'/>
    				<attribute name='po_oid'/>
    				<attribute name='po_defaultimage'/>
    				<order attribute = 'po_oid' descending='true'/>
    				<order attribute = 'po_defaultimage' descending = 'true' />
    				<filter type='and'>
    					<condition attribute='po_defaultimage' value='1' operator='eq'/>
    				</filter>
    			</link-entity>
    			<filter type='and'>".$spacefilter.$facfilter."
    				<condition attribute='statecode' value='0' operator='eq'/>
    				<condition attribute='new_latitude' value='".$lat1."' operator='ge'/>
    				<condition attribute='new_latitude' value='".$lat2."' operator='le'/>
    				<condition attribute='new_longitude' value='".$lng1."' operator='ge'/>
    				<condition attribute='new_longitude' value='".$lng2."' operator='le'/>
    				<filter type='or'>
    					<filter type='and'>
    						<filter type='or'>
    							<condition attribute='new_lowersize' value='".$low."' operator='le'/>
    							<condition attribute='new_lowersize' operator='null'/>
    						</filter>
    						<filter type='or'>
    							<condition attribute='new_uppersize' value='".$low."' operator='ge'/>
    							<condition attribute='new_uppersize' operator='null'/>
    						</filter>
    					</filter>
    					<filter type='and'>
    						<filter type='or'>
    							<condition attribute='new_lowersize' value='".$high."' operator='le'/>
    							<condition attribute='new_lowersize' operator='null'/>
    						</filter>
    						<filter type='or'>
    							<condition attribute='new_uppersize' value='".$high."' operator='ge'/>
    							<condition attribute='new_uppersize' operator='null'/>
    						</filter>
    					</filter>
    				</filter>
    			</filter>
    		</entity>
    	</fetch>
    	{% endblock %}
    	{% block template %}
    		{% spaceless %}
    		{% set previd = null %}
    		{% set nextid = null %}
    		<div id='sortme'>
    			{% for record in records %}
    				{% set nextid = records[loop.index0 + 1].new_buildingid %}
    				{% if record.new_buildingid != previd %}'
    					<div class='result' data-id='{{record.new_buildingid}}' data-location='{{ urlify(record.new_name) }}' data-location-test='{{ record.new_name|e('url') }}' data-lat='{{record.new_latitude}}' data-lng='{{record.new_longitude}}' data-price='{{record.new_costlower}}'>
    							<div class='result-slide'>
    				{% endif %}
    
    				{% if record.pp.po_powerphotoid %}<div class='result-image' style='background-image:url(/wp-admin/admin-ajax.php?action=msdyncrm_image&id={{record.pp.po_powerphotoid}}&width=800);'></div>{% else %}<div class='result-image' style='background-image:url(/wp-content/themes/cornerstone/assets/img/CS_Default-Image.png);'></div>{% endif %}
    
    				{% if record.new_buildingid != nextid %}
    							</div>
    							<div class='result-content'>
    								<div class='result-text'>
    									<h2>{{record.new_name}}</h2>
    									<h3>{{record.new_address1_line3}}{% if record.new_address1_line3 and record.new_address1_city %}, {% endif %}{{record.new_address1_city}}</h3>
    									<p>{{record.new_buildingdescription[:125]}}{% if record.new_buildingdescription %}...{% endif %}</p>
    								</div>
    								<div class='result-details'>
    									<div class='row'>
    										<div class='category {% if record.new_managedofficespace == 1 %}category-flexiblemanaged{% elseif record.new_servicedoffice == 1  %}category-servicedoffice{% elseif record.new_coworkingspace == 1  %}category-co-working{% elseif record.new_virtualoffices == 1  %}category-virtualoffice{% elseif record.new_leasedoffice == 1  %}category-leasedoffice{% endif %}'>
    											<p>{% if record.new_managedofficespace == 1 %}Flexible Managed{% elseif record.new_servicedoffice == 1  %}Serviced Office{% elseif record.new_coworkingspace == 1  %}Co-Working{% elseif record.new_virtualoffices == 1  %}Virtual Office{% elseif record.new_leasedoffice == 1  %}Leased Office{% endif %}</p>
    											<div class='result-info'>
    												<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 19.94 19.94'><path d='M10,19.94a10,10,0,1,1,10-10A10,10,0,0,1,10,19.94ZM10,1a9,9,0,1,0,9,9A9,9,0,0,0,10,1ZM7.37,6.08a4.71,4.71,0,0,1,.5-.39,3.74,3.74,0,0,1,.59-.33,3.57,3.57,0,0,1,.69-.22A3.77,3.77,0,0,1,10,5.05,3.33,3.33,0,0,1,11,5.22a2.46,2.46,0,0,1,.84.47,2.18,2.18,0,0,1,.55.73,2.27,2.27,0,0,1,.2,1,2.48,2.48,0,0,1-.16.93A2.59,2.59,0,0,1,12,9a3.13,3.13,0,0,1-.53.51L11,9.92a3.75,3.75,0,0,0-.43.38.76.76,0,0,0-.22.42l-.14,1.07H9.25l-.1-1.17a.87.87,0,0,1,.11-.57,2,2,0,0,1,.39-.45,5.44,5.44,0,0,1,.53-.41,4,4,0,0,0,.54-.44,2.39,2.39,0,0,0,.42-.55,1.5,1.5,0,0,0,.17-.73,1.19,1.19,0,0,0-.11-.53,1.2,1.2,0,0,0-.31-.4,1.39,1.39,0,0,0-.47-.26,1.82,1.82,0,0,0-.57-.09,2.23,2.23,0,0,0-.72.1,3,3,0,0,0-.51.22,3.34,3.34,0,0,0-.34.22.41.41,0,0,1-.23.1.31.31,0,0,1-.3-.18Zm1.38,8.46a.93.93,0,0,1,.56-.86.91.91,0,0,1,.37-.07.89.89,0,0,1,.36.07,1,1,0,0,1,.5.5.89.89,0,0,1,.07.36.91.91,0,0,1-.07.37,1,1,0,0,1-.2.3.9.9,0,0,1-.3.2.93.93,0,0,1-.36.07,1,1,0,0,1-.37-.07A.87.87,0,0,1,9,15.2a.93.93,0,0,1-.19-.3A1,1,0,0,1,8.75,14.53Z' transform='translate(0 0)'/></svg>
    												<div class='tooltip-info'>{% if record.new_managedofficespace == 1 %}A managed office allows you to have a bespoke fit-out and arrange your own IT and telecoms, but in a fairly flexible manner in relation to contract commitment. One operator will take care of all elements including moving in and out, customisation and making sure the space fits your business needs.{% elseif record.new_servicedoffice == 1  %}'The full package’ option with negotiable contract length. A serviced office is your one-stop shop for a dedicated and private office for your company and come with internet and telecoms within the offering. For short or longer term arrangements, serviced offices offer a flexible but professional feel that allows growth and in an ever-changing business climate.{% elseif record.new_coworkingspace == 1  %}Ideal for sole traders, start-ups and those who just thrive on collaboration; co-working space provides you with a hot-desk or designated bank of desks within a building that incorporates other businesses. A straightforward option where you can rock up with a laptop and just get stuff done without the commitment of an entire office.{% elseif record.new_virtualoffices == 1  %}A great option for those who don’t yet need a work space, or for businesses that don’t require a base. A virtual office will provide a prestigious registered address where mail can be sent and organised, a telephone number and call answering or forwarding services, plus offer business facilities should you need them.{% elseif record.new_leasedoffice == 1  %}A leased office is the business version of buying a house. Similar to a mortgage, you will have a long term loan on the property (leases are for contract terms of 5 years+) and be solely in charge of what goes on under its roof. A leased option is perfect for established companies who are relatively stable in terms of growth and location.{% endif %}</div>
    											</div>
    										</div>
    										<div data-id='{{record.id}}' class='featured-shortlist'></div>
    									</div>
    									<div class='row'>
    										<ul>
    											<li>{{record.new_lowersize}} - {{record.new_uppersize}}</li>
    											<li>{% if record.new_costlower %}From £{{record.new_costlower}}{% else %}£POA{% endif %}</li>
    										</ul>
    									</div>
    									<div class='row'>
    										<div class='tube'>
    											<p>{{record.new_nearesttube}}</p>
    										</div>
    									</div>
    								</div>
    							</div>
    						</div>
    				{% endif %}
    				{% set previd = record.new_buildingid %}
    			{% endfor %}
    		</div>
    	{% endspaceless %}
    	{% endblock %}
    [/msdyncrm_inline]"); ?>
    Thread Starter Jon Brain

    (@brainjonbrain)

    Hi @alexacrm,

    Actually, I made a mistake when I said replacing [msdyncrm_inline] with [msdyncrm_twig] didn’t affect the site – in fact, it stopped the query working.

    Here’s the [msdyncrm_inline] snippet. Importantly, when [msdyncrm_twig] was used it didn’t complain about the new function, so I suspect it might be accepting it. However, since the change of shortcode broke the query I now need to work out a way of using [msdyncrm_twig] so I can confirm using [msdyncrm_inline] was the problem.

    I’m new to Twig, so any pointers you can give me will be great – but don’t feel you have to.

    Thanks,
    Jon

    <?php echo do_shortcode("[msdyncrm_inline]
    							{% block fetchxml %}
    							<fetch distinct='false' mapping='logical' output-format='xml-platform' version='1.0'>
    								<entity name='new_building'>
    									<attribute name='new_buildingid'/>
    									<attribute name='new_name'/>
    									<attribute name='new_providerid'/>
    									<attribute name='new_address1_line1'/>
    									<attribute name='new_address1_line2'/>
    									<attribute name='new_address1_line3'/>
    									<attribute name='new_address1_city'/>
    									<attribute name='new_address1_stateorprovince'/>
    									<attribute name='new_address1_postalcode'/>
    									<attribute name='new_lowersize'/>
    									<attribute name='new_uppersize'/>
    									<attribute name='new_costlower'/>
    									<attribute name='new_costhigher'/>
    									<attribute name='new_latitude' />
    									<attribute name='new_longitude' />
    									<attribute name='new_managedofficespace'/>
    									<attribute name='new_servicedoffice'/>
    									<attribute name='new_coworkingspace'/>
    									<attribute name='new_virtualoffices'/>
    									<attribute name='new_leasedoffice'/>
    									<attribute name='new_buildingdescription'/>
    									<attribute name='new_locationdescription'/>
    									<attribute name='new_nearesttube'/>
    									<link-entity name='po_powerphoto' from='po_oid' to='new_buildingid' link-type='outer' alias='pp'>
    										<attribute name='po_powerphotoid'/>
    										<attribute name='po_oid'/>
    										<attribute name='po_defaultimage'/>
    										<order attribute = 'po_oid' descending='true'/>
    										<order attribute = 'po_defaultimage' descending = 'true' />
    										<filter type='and'>
    											<condition attribute='po_defaultimage' value='1' operator='eq'/>
    										</filter>
    				        			</link-entity>
    									<filter type='and'>".$spacefilter.$facfilter."
    										<condition attribute='statecode' value='0' operator='eq'/>
    										<condition attribute='new_latitude' value='".$lat1."' operator='ge'/>
    										<condition attribute='new_latitude' value='".$lat2."' operator='le'/>
    										<condition attribute='new_longitude' value='".$lng1."' operator='ge'/>
    										<condition attribute='new_longitude' value='".$lng2."' operator='le'/>
    										<filter type='or'>
    											<filter type='and'>
    												<filter type='or'>
    													<condition attribute='new_lowersize' value='".$low."' operator='le'/>
    													<condition attribute='new_lowersize' operator='null'/>
    												</filter>
    												<filter type='or'>
    													<condition attribute='new_uppersize' value='".$low."' operator='ge'/>
    													<condition attribute='new_uppersize' operator='null'/>
    												</filter>
    											</filter>
    											<filter type='and'>
    												<filter type='or'>
    													<condition attribute='new_lowersize' value='".$high."' operator='le'/>
    													<condition attribute='new_lowersize' operator='null'/>
    												</filter>
    												<filter type='or'>
    													<condition attribute='new_uppersize' value='".$high."' operator='ge'/>
    													<condition attribute='new_uppersize' operator='null'/>
    												</filter>
    											</filter>
    										</filter>
    									</filter>
    								</entity>
    							</fetch>
    							{% endblock %}
    							{% block template %}
    								{% spaceless %}
    								{% set previd = null %}
    								{% set nextid = null %}
    								<div id='sortme'>
    					    			{% for record in records %}
    						    			{% set nextid = records[loop.index0 + 1].new_buildingid %}
    						    			{% if record.new_buildingid != previd %}'
    						    				<div class='result' data-id='{{record.new_buildingid}}' data-location='{{ urlify(record.new_name) }}' data-location-test='{{ record.new_name|e('url') }}' data-lat='{{record.new_latitude}}' data-lng='{{record.new_longitude}}' data-price='{{record.new_costlower}}'>
    						    						<div class='result-slide'>
    										{% endif %}
    
    										{% if record.pp.po_powerphotoid %}<div class='result-image' style='background-image:url(/wp-admin/admin-ajax.php?action=msdyncrm_image&id={{record.pp.po_powerphotoid}}&width=800);'></div>{% else %}<div class='result-image' style='background-image:url(/wp-content/themes/cornerstone/assets/img/CS_Default-Image.png);'></div>{% endif %}
    
    										{% if record.new_buildingid != nextid %}
    													</div>
    													<div class='result-content'>
    														<div class='result-text'>
    									 						<h2>{{record.new_name}}</h2>
    									 						<h3>{{record.new_address1_line3}}{% if record.new_address1_line3 and record.new_address1_city %}, {% endif %}{{record.new_address1_city}}</h3>
    															<p>{{record.new_buildingdescription[:125]}}{% if record.new_buildingdescription %}...{% endif %}</p>
    									 					</div>
    										 				<div class='result-details'>
    										 					<div class='row'>
    										 						<div class='category {% if record.new_managedofficespace == 1 %}category-flexiblemanaged{% elseif record.new_servicedoffice == 1  %}category-servicedoffice{% elseif record.new_coworkingspace == 1  %}category-co-working{% elseif record.new_virtualoffices == 1  %}category-virtualoffice{% elseif record.new_leasedoffice == 1  %}category-leasedoffice{% endif %}'>
    										 							<p>{% if record.new_managedofficespace == 1 %}Flexible Managed{% elseif record.new_servicedoffice == 1  %}Serviced Office{% elseif record.new_coworkingspace == 1  %}Co-Working{% elseif record.new_virtualoffices == 1  %}Virtual Office{% elseif record.new_leasedoffice == 1  %}Leased Office{% endif %}</p>
    										 							<div class='result-info'>
    											 							<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 19.94 19.94'><path d='M10,19.94a10,10,0,1,1,10-10A10,10,0,0,1,10,19.94ZM10,1a9,9,0,1,0,9,9A9,9,0,0,0,10,1ZM7.37,6.08a4.71,4.71,0,0,1,.5-.39,3.74,3.74,0,0,1,.59-.33,3.57,3.57,0,0,1,.69-.22A3.77,3.77,0,0,1,10,5.05,3.33,3.33,0,0,1,11,5.22a2.46,2.46,0,0,1,.84.47,2.18,2.18,0,0,1,.55.73,2.27,2.27,0,0,1,.2,1,2.48,2.48,0,0,1-.16.93A2.59,2.59,0,0,1,12,9a3.13,3.13,0,0,1-.53.51L11,9.92a3.75,3.75,0,0,0-.43.38.76.76,0,0,0-.22.42l-.14,1.07H9.25l-.1-1.17a.87.87,0,0,1,.11-.57,2,2,0,0,1,.39-.45,5.44,5.44,0,0,1,.53-.41,4,4,0,0,0,.54-.44,2.39,2.39,0,0,0,.42-.55,1.5,1.5,0,0,0,.17-.73,1.19,1.19,0,0,0-.11-.53,1.2,1.2,0,0,0-.31-.4,1.39,1.39,0,0,0-.47-.26,1.82,1.82,0,0,0-.57-.09,2.23,2.23,0,0,0-.72.1,3,3,0,0,0-.51.22,3.34,3.34,0,0,0-.34.22.41.41,0,0,1-.23.1.31.31,0,0,1-.3-.18Zm1.38,8.46a.93.93,0,0,1,.56-.86.91.91,0,0,1,.37-.07.89.89,0,0,1,.36.07,1,1,0,0,1,.5.5.89.89,0,0,1,.07.36.91.91,0,0,1-.07.37,1,1,0,0,1-.2.3.9.9,0,0,1-.3.2.93.93,0,0,1-.36.07,1,1,0,0,1-.37-.07A.87.87,0,0,1,9,15.2a.93.93,0,0,1-.19-.3A1,1,0,0,1,8.75,14.53Z' transform='translate(0 0)'/></svg>
    											 							<div class='tooltip-info'>{% if record.new_managedofficespace == 1 %}A managed office allows you to have a bespoke fit-out and arrange your own IT and telecoms, but in a fairly flexible manner in relation to contract commitment. One operator will take care of all elements including moving in and out, customisation and making sure the space fits your business needs.{% elseif record.new_servicedoffice == 1  %}'The full package’ option with negotiable contract length. A serviced office is your one-stop shop for a dedicated and private office for your company and come with internet and telecoms within the offering. For short or longer term arrangements, serviced offices offer a flexible but professional feel that allows growth and in an ever-changing business climate.{% elseif record.new_coworkingspace == 1  %}Ideal for sole traders, start-ups and those who just thrive on collaboration; co-working space provides you with a hot-desk or designated bank of desks within a building that incorporates other businesses. A straightforward option where you can rock up with a laptop and just get stuff done without the commitment of an entire office.{% elseif record.new_virtualoffices == 1  %}A great option for those who don’t yet need a work space, or for businesses that don’t require a base. A virtual office will provide a prestigious registered address where mail can be sent and organised, a telephone number and call answering or forwarding services, plus offer business facilities should you need them.{% elseif record.new_leasedoffice == 1  %}A leased office is the business version of buying a house. Similar to a mortgage, you will have a long term loan on the property (leases are for contract terms of 5 years+) and be solely in charge of what goes on under its roof. A leased option is perfect for established companies who are relatively stable in terms of growth and location.{% endif %}</div>
    										 							</div>
    										 						</div>
    										 						<div data-id='{{record.id}}' class='featured-shortlist'></div>
    										 					</div>
    										 					<div class='row'>
    										 						<ul>
    																	<li>{{record.new_lowersize}} - {{record.new_uppersize}}</li>
    																	<li>{% if record.new_costlower %}From £{{record.new_costlower}}{% else %}£POA{% endif %}</li>
    																</ul>
    										 					</div>
    										 					<div class='row'>
    										 						<div class='tube'>
    										 							<p>{{record.new_nearesttube}}</p>
    										 						</div>
    										 					</div>
    										 				</div>
    										 			</div>
    										 		</div>
    						    			{% endif %}
    						    			{% set previd = record.new_buildingid %}
    					    			{% endfor %}
    				    			</div>
    				    		{% endspaceless %}
    							{% endblock %}
    						[/msdyncrm_inline]"); ?>
    Thread Starter Jon Brain

    (@brainjonbrain)

    Thanks for that @wizardist – it hasn’t changed the outcome, though.

    Did you have any further thoughts having seen the environment details?

    Thread Starter Jon Brain

    (@brainjonbrain)

    Thanks @wizardist.

    Really odd that you are not seeing any error. How are you trying to call the function? I’m calling it within the context of the [msdyncrm_inline] shortcode, if that helps.

    Dropping the cache has no effect.

    Here are the environment details:
    PHP: 7.0.30 (detailed info here: http://westsidelondonhosting.co.uk/phpinfo.php)
    Wordpress: 4.9.7
    Plugins:
    Advanced Custom Fields Pro: 5.6.4
    All in one Favicon: 4.6
    Dynamics 365 Integration: 1.2.13
    Dynamics 365 Integration Premium: 1.2.3
    Gravity Forms: 2.2.6.5
    Gravity Forms Event Tracking: 2.1.1
    Gravity Forms User Registration Add-On: 3.9
    WP SEO HTML Sitemap: 0.9.6
    Yoast SEO: 7.8

    Thread Starter Jon Brain

    (@brainjonbrain)

    Hi @wizardist

    The function is in an include called by functions.php – there are a few other functions in the include, and they’re working as expected. The add_action() is in the outermost scope of the file.

    Do you think there might be some kind of caching active that might be circumventing my code?

    Thanks,
    Jon

    Thread Starter Jon Brain

    (@brainjonbrain)

    Thanks George – I’ve emailed your support team as requested.

    Jon

    Thread Starter Jon Brain

    (@brainjonbrain)

    Many thanks for the quick reply! I have sent a link to the problem via your website.

    Jon Brain

    (@brainjonbrain)

    I had the same problem as @bodry24 – update_post_meta() updating the meta data for the post I wanted it to update and – incorrectly – updating the meta data for its next adjacent one as well.

    Thanks for the solution!

    Works a treat! Thanks 🙂

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