web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Context of the current record in RESCO's HTML Web Resource on Form

(0) ShareShare
ReportReport
Posted on by 7,396 User Group Leader

Hi All,

I have been configuring my RESCO mobile app by adding forms, fields etc. I also want to add a Web Resource. Since I'm about to develop an application, I would need to pass the context of the record to the HTML web resource and be able to access the same.

Any ideas on how I can achieve the same? Also, how do I debug any JS on the Resco's HTML web resource. This is an IFrame that I have inserted.

Kindly advise.

Thanks.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Thomas David Dayman Profile Picture
    11,323 on at

    Hi Priyesh,

    Here is some sample HTML/JavaScript. Hopefully you can use it as reference. Apologies as its a bit messy.

    <!DOCTYPE html>
    
    <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
    <head>
    	<meta charset="utf-8" />
    	<title>Empty Offline HTML page</title>
    	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
    	<meta name="viewport" content="initial-scale=1, user-scalable=no" />
    	<style>
    		table, th, td {
    		border: 1px solid black;
    		border-collapse: collapse;
    		}
        table table, table table td {
          border:none;
        }
        
    		th {
    		padding: 5px;
    		text-align: left;
    		}
    	</style>
    	<script src="JSBridge.js
    "></script>
    
    	<script>
    		
    		function change() {
    			
    			MobileCRM.UI.EntityForm.requestObject(
    			function(entityForm){
    				
    				var id = entityForm.entity.properties["entityrecordid"]; //primaryid of record
    					makeChange(id);
    				},
    				function (err) {alert(err);},
    				null);
    			}
    			
    		function makeChange(id){
    			MobileCRM.DynamicEntity.loadById(
    				"entity", //entity name
    				id,
    				function(entityForm){
    
    					if(entityForm.entity.properties["optionset_field"]==100000001){
    						
    						updateRecord(entityForm);	
    					
    
    					} else
    					if (entityForm.entity.properties["optionset_field"]==100000000){
    					
    						updateRecord(entityForm);
    					}
    				},
    				function (err) {alert(err);},
    				null);
    			}		
    			
    			function updateRecord(entityForm){
    		
    				if(entityForm.entity.properties["new_field1"]){
    					document.getElementById("id1").value = entityForm.entity.properties["new_field1"];
    				}
    				if(entityForm.entity.properties["new_field2"]){
    					document.getElementById("id2").value = parseFloat(entityForm.entity.properties["new_field2"]);
    				}		
    		}				
    			
    			
    	</script>
    </head>
    <body onload="change()" onchange="change()">
    	<!--   <button onclick="change()">MANUAL RUN LOGIC</button>  -->
    	
    	<table style='width:100%' id='Testtable' >
    		<thead>
    		<tr>
    			<th width='relative_length'>
    				<div>Div1</div>
    				<input id='id1' />
    			</th>
    		</tr>
    		</thead>
    		<tbody>
    		<tr>
    			<td>
            <table width='100%' cellpadding='3'>
              <tr><div>Div2</div></tr>
              <tr>
                <td><input id='id2' type='number' style='width:100%' /></td>
              </tr>
            </table>
    	</tbody>
    </body>
    </html>


    If you have Windows 10 you can download the Field Service app from the store and follow this process.

    http://mehmetgunen.com/debugging-resco-mobile-crm-application/

    Although I think it might only work with the Resco.exe. If it doesn't work then in the past I have just published the changes and checked the results manually :/ without any debugging.

    Let me know if you have any more questions.

  • Priyesh Profile Picture
    7,396 User Group Leader on at

    Thanks a lot Thomas!! Your response is spot on. This is really very helpful.

    Just one more thing, do you also know where I can find SDK for this JS?

    Thanks!

  • Verified answer
    Thomas David Dayman Profile Picture
    11,323 on at

    www.resco.net/javascript-bridge-reference here you go.

  • Priyesh Profile Picture
    7,396 User Group Leader on at

    Thanks Thomas!!

    I hope this works as smooth as JS for D365.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans