Tuesday, 13 May 2014

CRM SDK : Smart Way to Use CRMSVCUTIL.EXE

Many times, we have to update entity and field during development, then if you are using Early Bound to save your time, here is I give you advice to update your basecontext class using CRMSVCUTIL.exe wisely.
1. Create Folder for your Output
2. Create a special folder I usually call as SDK
3. Put CrmSvcUtil.exe inside together with all of required .dll
image
4. Create a new File
image
CrmSvcUtil.exe /url:"http://aileengusnidev:5555/contoso/XRMServices/2011/Organization.svc" /out:"../Crosscutting/BaseContext.cs" /domain:mycrmdev /username:administrator /password:mypassword /serviceContextName:"BaseContext" /namespace:TFP.Xrm.Contoso /generateActions



5. Then save it as .bat file

6. Run your ,bat file

7. Back to your output folder you should find your File

image

8. Every time you have any update, then just execute your .bat file to update this.

Updated :

/generateActions is the additional parameter for CRM 2013 to including custom Action in Early Bound Class.

Hope it helps!

Monday, 12 May 2014

CRM 2013 Custom Action as Configuration Entity Replacement

In My Previous Post, I talked about Action in overview. It has great potential and power to extend your xRM Platform. Now, I want to share my experience to use Action to replace a Configuration Entity.

Many thing you can do with Action, this website gives a good example :

http://blog.sonomapartners.com/2013/11/crm-2013-custom-actions-the-end-of-configuration-entities.html

It gives me a good idea and brainstorming.

And here is my example :

1. Create a New Process with Type = Action, make it as Global if you have not decided what specific entity you will use.

image

2. Add Input Arguments, in my case : I have 1 input and 1 Output

image

3. Go to step and make a condition as you did before to create Workflow

image

4. Then after checking condition, create an action message, in this case I put Assign Value.

image

5. Here is assign your value

image

6. Repeat the same steps for SAP as well

image[22]

7. Here is your complete Action

image

8. Using .NET or Javascript you can call this action, remember Custom Action only be triggered by a Code.

This is a good reference :

http://a33ik.blogspot.co.il/2013/10/custom-actions-walkthrough-for-net-and.html

This is like a ‘Code Contract’ that only developers (CRM and Other Party Developer that will use it) to accept desire inputs to result an output, and it is single manageable, that is inside that Action itself.

You can manage your logic here, another application who wants to connect and call this action will only need to give input what do you want and give the output, otherwise, they will be failed to call this action, because you also can do validation inside your Custom Action, I will give you another example later.

But, if you have requirement that User can change it easily and very often, then my recommendation is you are suggested to still use Configuration Entity, since it is easy to be managed and can be managed using Import Wizard (Excel functionality) and no need to do activation then do deactivation again.

My example is for configuration that is not in high frequency changing rate.

CRM 2013 Let Me Introduce a Nice New Feature : Custom Actions

CRM 2013 is not merely about UI Refreshment. It’s also coming with new great features.
In this post, I would like to you know about one of the great features : CUSTOM ACTIONS.
 
Overview
 
Action in CRM 2013 is definitely a process that allows a non developer user to create it and add some logic same as well as Workflow, but Action is only be able to be called or triggered by a custom code, it can be client or server code, meaning that Javascript and C# can call Action.
So, we can combine logic from developer and non-developer to implement a business logic using Action. Actions can be defined for an entity, but Actions also can support for Global entity, meaning that not merely tied to a specific entity. Actions can be used to several CRM messages, such as CRUD, Assign, Set State, etc. It enables solution architect to extend and explore the xRM platform.
Here are some posts that can help you to understand Custom Action and how to setup this.
 
Specification
 
1. Action can be used to Global entity and a specific entity.
2. Custom Action can help you to extend xRM Platform
3. Custom Action can be triggered using Javascript or C#, or another language using CRM API, such as SOAP or REST methods.
4. Custom Action need to be activated first and can be edited later
5. Custom Action can be used to set static and dynamic field value
6. The most interesting thing is Custom Action can be used as Custom Message or Event Handle and can be registered by using Plugin Registration Tool! It means that you can extend xRM and do anything using this new custom message.
Such as : onSubmittedApproval Message, onCalculatedField, or whatever you want.
7. Do you know that you also can use Action to receive some input, do validation, and then manipulate the output? For example, for Approval Process needs validation and formula calculation.
 
Why We Should Use Action and When?
 
You can use Action anywhere and anytime. Wherever and whenever you need it since both client and server code supports this calling.
What scenario or business idea you can achieve using custom Action?
 
1. Say partial good-bye to Custom Entity that so-called as Configuration Entity

Last time using CRM 4 or CRM 2011, I remember I always use Configuration Entity or Configurable Parameter to store some information that can be called by third party application, such as Console or Web App or event Web Part from SharePoint that we can develop. Or for outside application, I can use web.config or app.config with encryption, etc.
For example : to store server URL, username and password, additional settings, such as : maximum permitted credit card account for each Customer, maximum Membership card for each Member, minimum monthly fee for rental as commitment, enable for approval checkin (yes/no) then if Yes, do something, if No then stops it, due date for submitting an activity for each month, etc. There are real condition that we often face and we cannot do hard-coding, right.
Let’s say after an Order created, then pass the information to Navision (integration to Navision), then we have to detect in the Plugin onCreate, pass information to which Navision Server? Then what we do is by reading a custom entity so-called Configuration. It’s fine to use this conventional way, but don’t forget to make validation as well, cannot have more than one record to store Navision Server URL, don’t want to make system being confused.
Now, you can achieve this.
 
2. To show a Custom Error Messages
 
Many times, we have plugin and we should show a error messages, for example : “Please input ‘City’ value! or ‘City’ cannot be blank!
Then, what we do often is do hard-code in the Plugin or again, using the first method, reading Configuration entity that store some error messages.
Imagine, you have many plugins and you have to reading that entity and imagine that you have to change your words later. For example, now the message is “Please input ‘City’ value!, then later your customer says I don’t want to use that statement, I want a more polite word : “Sir/Madam, please fill the ‘City’ value. The developers statement for some errors can be different from what customer want, and what happened if you hard-code it.
 
3. Custom action as Custom Message
 
Several times, I was being forced to trigger a plugin using JavaScript by creating a dummy record to fix a complex business flow requiring a complex code. Custom action can be used as custom action and you can register your action same as well you register your Plugin Message.
 
4. Custom action to solve complex Business Requirement
 
I often have requirement that should be easier if I code it using server code, for example : Calculation, Approval, Third Party Integration, such as SMS, Product Configuration, the want they I can do is I have to write a custom code of workflow activity, a custom web service, a batch scheduler job, or trigger a plugin. Using action, based on point number #3, since Custom action can be used as custom message, then we can use Custom Action to implement our complex logic and it is easy to call custom action. To know more about this, I promise I will give you example on my next posts.
 
5. Custom action is a single point of integration.
 
Can you imagine if you are trying to do integration for other system, both inbound or outbound that you should write many custom code.
For example, if you want to pass information from your website to CRM, then you can do either you write code in your website code call CRM API, or you use web service, let’s say you are trying to have a business logic for creating a lead from several websites and POS System, and as well you can create directly using CRM Import Wizard. How many point of gate you have?
 
Imagine, you have 3 websites (one for case support and enquiry, one is forum discussion, one is public official website), 2 Desktop Apps (one is for Agent at a branch and one is you put at kiosk), and 1 Console Job Application (for retrieving data every day collecting Social Media interaction), then you have at least 6 gates from your another application that customer wants you to let them generating lead or contact from all of six apps. Then what you is you can implement your code of all of your 6 apps, imagine you have 6 apps but all of them having one purpose and having a lot of Input Arguments that should be same, then you have to do 6 times, implement your code, or smart way is you can use a web service to be called by them. Instead using web service, you can using Action (refer to point number #2, you can use Custom Action as Custom Message).
 
Let’s say other example, you have a Quotation that you should let the salesperson to input : Total Amount, Tenure, Interest Rate, and Discount Rate to calculate Net Monthly Rental. For CRM apps, every time you create quotation or every changes of those 4 fields, you have to re-calculate again, so meaning that you have to create a plugin onCreate and onUpdate then you have to implement the code for two of them.

Then, your customer also have another web apps, mobile apps, and a desktop apps to calculate Net Monthly Rental using same Formula and Same Inputs as well to get one Output, that is Net Monthly Rental. Imagine, you have to write code and put into all of them, including two plugins and 3 apps, yes you can copy paste, but later let’s say your formula has been changed, now your monthly rental is not only about Total Amount plus interest divide by tenure, but your salesperson also can quote a committed amount, for example additional installment 1% of Total Amount if the Monthly Rental is less than USD 10,000, etc.
 
Then, you have to re-develop again your logic in every part you put in, 2 plugins and 3 apps at least. In this scenario, actually you can using custom action to put your calculation logic inside then all of your apps can call this action, including using Javascript or Server Code. You just input arguments and get the output. The arguments will be the input and be used for calculation inside the custom action logic to get the output as a result.
Okay, I think better if we got an example, please refer to my next posts.
 
Note
 
During import a solution that containing a Custom Action, you might be facing an error : Workflow with Id {Guid} does not exist.

To avoid that error, please refer to use this blog link to guide you :
 
Hope it helps!
 

CRM 2011/2013 Display or Show a ‘Disabled Sitemap Area’ Entity in Sitemap

Some entities is unable to be placed in sitemap. For example :
Opportunity Product
image
Users
image
Territory
image
Price List
Product
image
But, actually you are be able to do it.
image
image
Here I can show you how you can display Opportunity Product, Users, Territory, Price List, Product, etc. in a sitemap.
I give example to add Opportunity Product into Sales Area
You can do it by updating your customization for sitemap definition xml by adding subarea to opportunityproduct.
<SubArea Id="" Entity="opportunityproduct">
      <Privilege Entity="tfp_sitemapsales" Privilege="Read" />
</SubArea>
Inside your Sales Area
For easier way, I recommend you use a sitemap editor, that you can download here together with other toolbox.
This tool is so brilliant.
http://xrmtoolbox.codeplex.com/releases/view/116287
So I am going to make Sitemap Editor as prerequisite to make your life easier.
Here is the way :
1. Download the sitemap editor
2. Run the sitemap editor
3. Load your sitemap until you can see your Area
image
4. Then expand the area that you want to display inside (Sales Area – Area (SFA))
Expand your Area, then decide where do you want to place your Entity, remember you also can Move Up and Move Down your area easily using this tool.
5. Then you fill everything, the main thing is in the Entity –> Select Entity
image
6. You can see after you OK, then you will get the entity schema name : “opportunityproduct”
image
Save it.
7. Publish your sitemap by pressing the “Update Sitemap” button
image
8. See the result :
image
image
and Territory into a custom area : Master Data
1. Do the same thing, repeat all of the steps, but don’t forget to Create the Master Data area first in your sitemap to enable subarea fill this Area.
2. Now, you are not going to Sales area, but to Master Data area (of course after you added the Master Data area)
image
3. Do the same thing, especially for step number #5 before, but using Territory instead of Opportunity Product entity
image
image

image
Notes :
You also can change the Icon and Title, and control sitemap Privilege as well, for example you want to control Customer Service cannot see the Territory Master Data in sitemap, etc, but can read the entity record data.

Thursday, 8 May 2014

CRM 2013 Get Record Guid

Sometimes, for tracing and testing, we always need Guid from record that we view in CRM web.
If in CRM 2011, you can easily grab the current guid by pressing F11, Ctrl + N and also easier because it opens a new pop up.
SNAGHTML7396772
Then, if CRM 2013, when you click record from Grid View or from anywhere, you might be only having this screen :
image
You have been in that Account record, but you still cannot see the URL since it did not open new pop up.
If you press F11, you also can get full screen only.
image
There are some method to get that Id
1. Do a SQL Query using name field combined with Address fields, maybe. But, again, need more effort.
2. Click the “Pop Out” from the record form to get the URL :
image
Then you can grab the URL as usual :
image
3. If you are so lazy to do that, just go to this link :
http://mscrmtools.blogspot.com/2013/11/an-easy-way-to-find-id-of-record-what.html
And download and Import the solution.
image
Then get the ID directly
image
Hope it helps!

CRM 2013 Custom Action Import Solution Error


When you import a solution that having a custom action component, you might be facing error or failure :
Importsolutionfield1
With error : “The requested record was not found or you don’t have permission …”
Then when you download log file :
Importsolutionfield2
Workflow with Id = ‘Guid’ Does Not Exist
After tried to find out, we know that this solution never get any error before we have Custom Action component inside.
I realize that it might be missing ID when try to import related record between that workflow (which is Custom Action type) and its child, such as Argument, Steps.
Resolution :
1. If you want really still use that Custom Action and Improt it to another organization, then first your have to Remove all of the Arguments and Steps.

Then, you export import your solution (you can add your Custom Action – without Arguments and Steps – as your Process component), then it should be working.
Then, later, from your source organization, you can continue your Custom Action development by re-do inserting your Arguments and Steps.
After that, because in your destination organization, your workflow Id has been inserted, then any update from your custom action, you will not find any error.

2. Alternatively, you can create a special solution (separately) containing only custom actions (that you already created the header, but you have not inserted any arguments or steps), let’s say you still yet to decide where is your destination organization, than you can create custom action as many as you want, add that to your special solution, then after that you export that solution (the one that containing blank custom actions), then you save it first in your local computer. Later, when you want to import your complete solution, first you have to import your blank custom action, then you can continue import your rest solution development/customization.
Create a new solution
image
Add custom action (blank), make sure you do not have any arguments or steps first, otherwise, you have to remove all then re-add again.
image
Publish all customizations, then you export solution, then do not forget to save it.
image
After all, you should have imported this solution first before you can import your complete solution that your custom action is not blank anymore because you have added some arguments or steps.
I hope in the next rollup of Microsoft Dynamics CRM, this issue can be fixed, I try this method since I really urgent to export and import my solution, and I cannot stand every time I have to recreate and re-add arguments and steps.
Hope it helps!

Monday, 5 May 2014

CRM 2011/CRM 2013 Import Solution Error : The 'label' attribute is not declared.

When you export and import your solution, you might be having this problem :
image
Even, you cannot go process further.
Then you click to go to Technical Details.
image
You can see this error :
The 'label' attribute is not declared.
fp_/Scripts/Common.js" libraryUniqueId="{2bc9de70-3eba-6b5d-a312-7dce0cc2bd19}" /><Library name="tfp_/Scripts/QuoteProduct.js" libraryUniqueId="{ead514c4-523c-5a70-6c46-53d6bedcce82}" /></formLibraries></form><LocalizedNames><LocalizedName description="Information" languagecode="1033" /></LocalizedNames><Descriptions><Description description="A form for this entity." languagecode="1033" /></Descriptions></systemform></forms></FormXml><SavedQueries><savedqueries><savedquery><IsCustomizable>1</IsCustomizable><CanBeDeleted>1</CanBeDeleted><isquickfindquery>0</isquickfindquery><isprivate>0</isprivate><isdefault>0</isdefault><returnedtypecode>1085</returnedtypecode><savedqueryid>{b8dab044-44d1-e311-940e-001cc4eecdd6}</savedqueryid><layoutxml><grid name="quotedetails" object="1085" jump="" select="1" icon="1" preview="1"><row name="quotedetail" id="quotedetailid"><cell name="productname" disableMetaDataBinding="1" LabelId="query.product.cell.productname.label" width="150" disableSorting="1" label="Product Name" /><cell name="productid" ishidden="1" width="200" disableSorting="1" /><cell name="productdescription" ishidden="1" width="200" disableSorting="1" /><cell name="priceperunit" width="100" disableSorting="1" /><cell name="quantity" width="100" disableSorting="1" /><cell name="manualdiscountamount" LabelId="query.product.cell.productname.discount" width="100" disableSorting="1" label="Discount" /><cell name="extendedamount" width="125" disableSorting="1" /><cell name="tax" width="100" /><cell name="uomid" width="100" /><cell name="sequencenumber" ishidden="1" width="100" /></row></grid></layoutxml><querytype>0</querytype><fetchxml><fetch distinct="false" mapping="logical"><entity name="quotedetail"><attribute name="productid" /><attribute name="productdescription" /><attribute name="priceperunit" /><attribute name="quantity" /><attribute name="manualdiscountamount" /><attribute name="extendedamount" /><attribute name="sequencenumber" /><order attribute="sequencenumber
Then you go and find labels=”
image
Then you know that you are not supposed to have “label” attribute in this schema.
And you know that in your customization.xml actually you have two “label”
Then, here is the resolution :
1. You can remove that troublesome attribute from customization.xml by extracting your .zip solution file then find : “label=”
image

image
Then you remove those attributes to become that :
image
Then you do zipping again for all of the solution folder
image[72]
And actually it works.
image
Thanks to this link for giving me clue.
http://nishantrana.wordpress.com/2013/02/06/the-label-attribute-is-not-declared-error-while-importing-solution-in-crm-2011/comment-page-1/#comment-22984
2. If you are still in development and very often to export and import your solution between two organization, you feel tired to change that customization.xml, there is another way, that is by fixing the error from your source organization.
Here are the steps :
1. First, you go back to your troublesome customization.xml or the dialog message from technical details and find the ‘savedqueryid’
image
Then you go to SQL, query using that savedqueryid to get the View Name
image
Get your Saved Query Name and then you go to your source organization and then delete that field.
Then, you go to your View and delete that view.
Then, you export back your solution and import again and you know that it works.
Hope it helps!

Aileen Gusni

Aileen Gusni