Sometime we need to apply some operations on selected records in home page entity view by clicking on custom button. To apply operations, firstly we need to get GUID of these selected records then we can apply any kind of operations of these records. In this post, i will show you how to retrieve GUID of selected records.
Step 1: Copy the below code and paste it in your Java-Script file .
function selectedRecord(selectedIds) {
if (selectedIds != null && selectedIds != "") {
var strIds = selectedIds.toString();
var arrIds = strIds.split(",");
for (var i = 0; i < arrIds.length; i++) {
alert(arrIds[i]);
// do your operations here
}
}
else {
alert("No records selected!");
}
}
Step 4: In this Action, add lib. and give the Function Name.Here our function is selectedRecord. Now click on parameter to get selected records GUID.
Step 5: Click on Add to add a new parameter. And then select the CRM Parameter option.
Step 6: Value of parameter is SelectedControlSelectedItemsIds as show in below Snapshot.
Step 7: Now select your command in command bar and then publish your solution.
Now do the testing. Select the records and then click on button. you will get GUID of these selected records.
Step 5: Click on Add to add a new parameter. And then select the CRM Parameter option.
Step 6: Value of parameter is SelectedControlSelectedItemsIds as show in below Snapshot.
Step 7: Now select your command in command bar and then publish your solution.
Now do the testing. Select the records and then click on button. you will get GUID of these selected records.
6 comments:
Hi
I was able to create button and get record's GUID of selected records from the above steps.
In each record I have one field named "Approved".
The actual functionality which I wish to have is 'On clicking button, the 'approved' field should be set to 'Yes' for selected records'. Is this possible to set field's value using records's GUID?
Hi Preksha,
Yes this could be possible. After got the GUID of selected records, Update these records using WebApi (Set field's value to yes )
this is not giving GUID. I am getting the result as Object
very helpful, thank you
Yes its worked. Very useful blog
Very useful blog. Its worked. Thank you
Post a Comment