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

Community site session details

Session Id :
Dynamics 365 Community / Blogs / Bring your code 2 life / How to quickly update an at...

How to quickly update an attibute from a browser bookmark

Andreas Cieslik Profile Picture Andreas Cieslik 9,267

 As a developer or tester sometimes its really nice to have a direct way to update an attribute on the current record.

To accomplish that you can simply bookmark a new page in e.g. Chrome and add this little piece of JavaScript into the URL field:

javascript:(function(){const curId=Xrm.Page.data.entity.getId();const entName=Xrm.Page.data.entity.getEntityName();const fldName = window.prompt("Please enter the attribute name");const fldValue = window.prompt("Please enter the attribute value");const jsdata={};jsdata[fldName]=fldValue;Xrm.WebApi.updateRecord(entName, curId.replace(/[{}]/g, ''), jsdata).then(function success(result) {window.alert('${entName} was successfully updated');},function (error){window.alert(error.message);});})()

An alert box will ask you for the internal attribute name and a second for the value.
This might not be the best way to do it but it will give you a clue on how to change it for your own needs.

(This script will only work for simple field types e.g. integer, string, etc.)


This was originally posted here.

Comments

*This post is locked for comments