Is it possible to rename Status options (Active/Inactive) of a Custom Entity? - dynamics-crm-2011

I've a custom entity, Fee. For the status reason of this entity I've already modify Inactive to Processed. Now I want to rename its inactive status option to Completed.
Is it possible or any workaround to this will be handy.

There is no out of box way to do this.
But there is a Trick.
You can export Translation for Statecode (Active/Inactive) and in label change it to whatever you like and then reimport it to CRM. This shall reflect the changes.
I just tried this in one of my demo instance on Account Entity. I changed Inactive to Inactive Test and it did reflected.

Related

CRM 2011 Workflow not triggered before mandatory fields are checked

I am looking to create a workflow that will populate any mandatory fields that do not contain data when a company is deactivated. The mandatory fields are either not populated because of legacy data or because the mandatory fields have changed since the record was created.
The issue I get is that the mandatory field check takes place before the workflow is triggered.
My workflow looks like follows:
If Status = Inactive
If Company Name does not contain data
Then update to ‘Test’
I have come up with a possible solution:
• Create a new button in the ribbon that runs the workflow on-demand and apply permissions to this button.
If possible though I would like to do this through a workflow that is triggered on clicking of the ‘Deactivate’ button. Any ideas are welcome.
In your situation the record will not be saved until the mandatory fields are filled, and a workflow cannot be triggered if a record is not saved first.
An approach to solve this situation is to write a JavaScript attached to the OnSave event, but you need a rule to be able to identify the legacy records, so this JavaScript (that will fill the mandatory fields for you) will not run for normal records.
This approach is not tested, but with some tweaks should work.

CRM - how to add the case number to appointments

On CRM in the appointments you can click on the regarding tab to open up that appointments Case details.
Is it possible to add the CASE number for that appointment to the appointments page. Reason being every time I want to see the case number I need to click on regarding tab and open up another webpage.
Would be nice to just have the case number appear on the appointment page, anyway on the page is fine.
Is this possible?
thanks
I agree with Alex and Disagree with Darren, although a plugin would get the job done it seems very excessive for what you are trying to accomplish.
The best way to do this between entities is to use the mapping fields between entity relationships however i don't believe CRM allows this between case and appointment in which case i would create a workflow.
Create a workflow on appointment firing on create or on-change of the regarding field, pull the case number field from the case entity when regarding is on case. This workflow will fire every time this event happens however you can build some extra logic around it and if there isn't a case entity no data will be pulled through.
Hope this helps
You can write a plugin on create and/or update of the regarding field on Appointment. Within this plugin you can check if the regarding field is populated and if so if the entity type is incident. If it is, obtain the Case Number (using the OrganizationService) and set the value of a custom attribute on the triggering Appointment.
Add the custom attribute to the Appointment form. Generally this kind of reference information goes in the header section but it's entirely up to you. If you don't place it there make sure you mark it as read-only.
Depending on your use case you may also want to check in the plugin when the regarding field changes. If the regarding is removed or changed you'll need to make sure you update the case number on the Appointment to reflect this.

update netsuite parent field via suitescript in view mode

I have scripts that react off of, for example, a client Recalc client event. For example, on my form I have a subtab that users may add or remove items from. Based on actions on this subtab (housing a child record of the parent) I would like a field on the parent to update (say to show a total from the children records).
As I was saying, these events seem to work fine if in edit mode but they do not work correctly in view mode. (even in view mode these child records have a "Delete" option at the end of each row in the subtab. This was provided by netsuite by default.
I wondered if anyone had any tips to best allow this parent field to update real time while in updating the subtab rows with the form in view mode.
Thanks.
You can make a custom field on the parent (header) whose value is determined by saved search. For instance, make a saved search that totals the line values by transaction. Be sure to make it filter by transaction in the Available Filters tab. Make the search public so everyone can use it.
Create the custom field that sources the total from the saved search. Make sure to uncheck the "Store Value" checkbox, as you don't want to store the data, you want to reference the search results. You do this on the Validation and Defaulting tab. You'll see a field for Saved Search there. Choose the search you created above.
As you remove/add/change lines on the transaction, the field updates accordingly. In essence, you don't need a single line of code to make this work - it's all in how you create the search and the custom field that references it.
I have a similar situation posted here.
The NetSuite team answered me by email, and it happens you can't really achieve this on the view mode: some API methods are not available. Their suggestion to my case (and I think it applies to yours too) was really to force a refresh on the whole page.
Of course, you can always achieve this accessing the DOM elements directly, but this isn't a best practice, as your code can stop working if these elements change on a version update.
I had the same problem, I'm not able to restrict on view or remove edit button. But, there was one alternative solution with workflows, you can deploy workflow on child record edit mode restrictions, then if the user clicks edit on view then the record will not be available to edit. This concern will apply to custom record as well.

How to add value to a field from another lookup field?

I have a custom entity Partnership in which I have one lookup field contacts.
now I want to add the name field value of the partnership from contact fullname in time of creation of Partnership.
is it possible with the help of pre-existing configuration settings,(without plugin or web resource)
Thanks.
Without using a plug-in or web resource you have a couple options.
1- You can configure the mappings between the 2 entities by going to the Entity (contact) -> Relationship -> Mappings -> and add a new mapping there. For this to work though, you will need to create the child record from the subgrid of the contact, and if the contact changes it won't update the values. So it may or may not be an ideal solution for you.
2- You can create a workflow rule that runs on create and/or update of the Partnership record that pulls the value from the parent contact onto the partnership record. The downside of this is that workflows are async so you won't see the update for a few seconds and refresh the Partner record.
Hope this helps.
If you want to be able to click the "New Partnership" button in the CRM ribbon, then select a contact, and have the name of the contact, be used to populate another field on the form, you will have to use JavaScript. There is no configurable way of doing it.
If you'd like the value to be populated before it is saved in the CRM database, you could use JavaScript, or a custom Plugin. If you'd like the value to be updated after the record is created, you could use a workflow.
You'll have to use one of those three methods to populate the field. The real question I have though, is why are you bothering to populate the field in the first place? You can add the full Contact name to any view, so I don't see a real big reason to include it.

How should I implement `OnLoad` event handler when creating an activity using a contact?

I've created my own solution with a custom entity of type activity. I'd like to show a message whenever a new instance of it is created using an existing contact but not allow the user to create one, if only attempting to do that without going via contact.
Basically, my aim is that it won't be impossible to just create that activity (the form will be hidden directly at any attempt except for one way only). The user will have to go to contacts (or leads etc.) and in there add and create an instance of the custom activity entity. That way, I can assure that the field "regarding" will be filled out already.
I'm guessing that I need to detect somehow that the opening of the form is a creation attempt. How can I do that?
Also, as it is now, the user can't create a contact-less activity of the custom type because it doesn't appear on the menu with other activities. I must have disabled it somehow but I have no idea how. Anybody who has one?
You could do this a bunch of ways but the easiest would probably be to:
Make the regarding field read only.
Make the regarding field mandatory.
That way if a user opens a create new form they wont be able to set the regarding and because its mandatory they wont be able to save the record. When they open via an existing contact the regarding field will be mapped automatically. That said in this case just making it mandatory my be enough.
(As a side JavaScript can be used to identify the current form state, but I'm not sure how useful that is here).
In terms of where custom activities appear, by default mine show in a number of locations, for example:
CRM > Workplace > Activities > Ribbon > Other Activities > XXX.
CRM > Workplace > Activities > View Selector > XXX.
They don't show under the left hand navigation of the workplace because they are grouped under 'Activities'. I'm pretty sure these are all the default settings.
You can exercise greater control by editing the sitemap, where you can put pretty much anything, anywhere.
In addition to Mr Wood, I'd like to show you some code. It works as supposed to but I'm not sure if it's optimal.
var foo = function () {
var whatIsGoingOn = Xrm.Page.ui.getFormType();
if (whatIsGoingOn === 1)
alert("Let there be an entity!");
else
alert("Not a creation...");
}
The other states' (deletion, update etc.) numeric values are listed here.
Answering the second part of your question:
When you create a custom activity you can choose whether to have it appear in 'normal' Activity menus or not by checking the box at the top right of the entity form. This is a once-only choice as far as I know and can't be changed later.
For your setup, I would suggest NOT checking this box, so it does not appear in the activity menus to avoid users even being tempted to do it that way.
Instead, add an explicit relationship to the activity N:1 to Contact, and another N:1 to Lead. Use this relationship to add your activity to the left navigation of Contact and Lead forms, or add a grid for them (depends on how you want to use this and if you need to filter the view to something other than the default "Associated View").
When a user navigates to this section they will see if any previous activities of this type exist, and be able to add a new one. BUT this means that the child record is a child via this relationship, not using "regarding", so use a script on the form for the activity so that if Contact is filled in, it is copied to Regarding, and if Lead is filled in then that is copied. If neither, then use an alert or other means to warn the use that something is wrong (see comment earlier). If you want Regarding to be read-only but filled in by script, you will need to make sure to use the force the value to be saved:
Xrm.Page.getAttribute("regardingobjectid").setSubmitMode("always");
You must have the lookups for Contact and Lead on the form to be able to use them in your scripts, but you can make them not "visible by default" so they are there but not seen by the user (and taking up no space).

Resources