Answered by:
Business Rule

Question
-
Hello,
So, I have created an Account form and then when I choose Customer on Relation Type field (Account Entity), i want to make a Bank Account (Bank Account Entity) disapear from the form. So, can I do that using a Business Rule like linking an Entity to another Entity? or is there any other ways to make this happen?
Thanks & Regards,
Indra
Thursday, April 13, 2017 4:28 AM
Answers
-
Hauw,
I'm afraid that your requirement can't be implemented using Business Rules. You will have to learn how to write JavaScript for that purpose. Here is what you will need:
1. How to get value of field - https://msdn.microsoft.com/en-us/library/gg334409.aspx#BKMK_getValue
2. Change visibility of section - https://msdn.microsoft.com/en-us/library/gg328489.aspx#BKMK_sectionSetVisible
Feel free to post your updates here including your code.
Dynamics CRM MVP
Read My blog
Subscribe for one of my courses- Proposed as answer by Andrii ButenkoMVP, Moderator Monday, April 17, 2017 4:03 AM
- Marked as answer by Hauw Indra Monday, April 17, 2017 4:24 AM
Monday, April 17, 2017 4:03 AMModerator
All replies
-
I've read another forum. And they say I can use workflow, but I don't know where can I find workflow on Dynamics 365. Can anybody help me find where the workflow is?
hehe :)
Thursday, April 13, 2017 7:51 AM -
Hauw,
Just set requirement level of field to "required" and publish the field.
Dynamics CRM MVP
Read My blog
Subscribe for one of my courses- Proposed as answer by Andrii ButenkoMVP, Moderator Thursday, April 13, 2017 12:24 PM
Thursday, April 13, 2017 12:24 PMModerator -
Hello Andrii,
the field requirement was already required. can you help me how to make a Bank Account (Grid) disapear when i choose Customer in Relation Type(Field)?
Thanks,
Hauw
Monday, April 17, 2017 3:54 AM -
Hauw,
I'm afraid that your requirement can't be implemented using Business Rules. You will have to learn how to write JavaScript for that purpose. Here is what you will need:
1. How to get value of field - https://msdn.microsoft.com/en-us/library/gg334409.aspx#BKMK_getValue
2. Change visibility of section - https://msdn.microsoft.com/en-us/library/gg328489.aspx#BKMK_sectionSetVisible
Feel free to post your updates here including your code.
Dynamics CRM MVP
Read My blog
Subscribe for one of my courses- Proposed as answer by Andrii ButenkoMVP, Moderator Monday, April 17, 2017 4:03 AM
- Marked as answer by Hauw Indra Monday, April 17, 2017 4:24 AM
Monday, April 17, 2017 4:03 AMModerator -
Andrii,
OK. I'll try it.
Thank you so much for your kindess.
Monday, April 17, 2017 4:23 AM -
function BankAccountDisapear(Context){ var relationType = Context.getEventSource(); if(relationType.getValue == "Customer") { Xrm.Page.getElementId("aBankAccount_d").sectionObj.setVisible(false); } else{ Xrm.Page.getElementId("aBankAccount_d").sectionObj.setVisible(true); } }
Here's my code. But there's an error message when i try it :
TypeError: Cannot read property 'sectionObj' of null at BankAccountDisapear
thanks
Tuesday, April 18, 2017 8:48 AM -
I see bunch of issues in your code. Here is fixed version - you will need to replace places with correct attribute/tab/sections names:
function BankAccountDisapear(){ var relationType = Xrm.Page.getAttribute("put your relationship schema field name here").getValue(); if(relationType === <put integer value for Customer optionset value here>) { Xrm.Page.ui.tabs.get("put tab name here").sections.get("put section here").setVisible(false); } else{ Xrm.Page.ui.tabs.get("put tab name here").sections.get("put section here").setVisible(true); } }
Dynamics CRM MVP
Read My blog
Subscribe for one of my coursesTuesday, April 18, 2017 12:41 PMModerator -
I've tried your code but there's an error said :
TypeError: Cannot read property 'getValue' of null at BankAccountDisapear
Thursday, April 20, 2017 7:32 AM -
Please provide code you use. I have no superpowers to see it.
Dynamics CRM MVP
Read My blog
Subscribe for one of my coursesThursday, April 20, 2017 12:51 PMModerator -
Lol.. Sorry :D
function BankAccountDisapear(){ var relationType = Xrm.Page.getAttribute("CustomerTypeCode").getValue(); if(relationType === 3) { Xrm.Page.ui.tabs.get("SUMMARY_TAB").sections.get("BankAccount").setVisible(false); } else{ Xrm.Page.ui.tabs.get("SUMMARY_TAB").sections.get("BankAccount").setVisible(true); } }
Friday, April 21, 2017 2:13 AM -
Replace line
var relationType = Xrm.Page.getAttribute("CustomerTypeCode").getValue();
with line
var relationType = Xrm.Page.getAttribute("customertypecode").getValue();Dynamics CRM MVP
Read My blog
Subscribe for one of my courses- Proposed as answer by Andrii ButenkoMVP, Moderator Friday, April 21, 2017 2:56 AM
Friday, April 21, 2017 2:56 AMModerator -
ANDRIII...
IT WORK.... THANK YOU SO MUCHHHHH......... :D
sorry for asking to much question..
Friday, April 21, 2017 7:09 AM