The GUID of the entity on a custom field - guid

I want to create a custom textfield in a serviceactivity. When the serviceactivity onloads I would like to have the serviceactivities GUID in that textfield. Does anyone have any idea how I can solve this?

Sure.
Create a new attribute (myguid) on the entity to hold the GUID.
Go into the main form customization for that entity.
Add the new myguid field to your form.
On the form properties, alter the onLoad event.
Use crmForm.ObjectId to get the GUID value.
Example:
crmForm.all.myguid.DataValue = crmForm.ObjectId;
You might wanna check out the CRM 4.0 SDK.

Related

Editable field action in sonata list view

I have a list view in sonata admin. I want to edit integer field directly in list view. New data for this field must change other fields in my entity. How can I add action function to this editable field in which I may do some actions with other fields depending on entering integer value?
Please check documentation: https://sonata-project.org/bundles/admin/master/doc/cookbook/recipe_custom_action.html
Basically, what you need is a custom route and and a controller, same way as you handle any page/request. Than you can do any logic you like making requests to this routes (even with AJAX). Documentation will help you the best with this.
And to add an "editable field" or a link or a button in List view, just create custom template piece: https://sonata-project.org/bundles/admin/master/doc/reference/templates.html

Hide some fields from view in ASP.Net MVC

I have a table with CreatedBy ModifiedBy and Isactive columns. Using Entity Framework Database first renders all the fields in create, detail and list views. I am automatically creating views by using "MVC 5 Controller with views, using Entity Framework" option.
I want views to don't show these fields and assign values in controller to it. I already tried [ScaffoldColumn(false)] but it works only with #Html.DisplayForModel()
What should i do to achieve this?
I would recommend to use ViewModels. That means you can map your db poco entity to physical representation of your View (known as ViewModel). Then, you can show whatever you want. When you do not want to update some columns, you can hide it using CSS or make it just read only. On your controller side (update action) you just read properties you want to update.
I recommend to follow this topics to get to know more about VM: What is ViewModel in MVC?

How to add ajax property to an existing field in a content type in drupal

I have created content type with several fields. I want to add an ajax property to some fields in that content type using hook_form_alter.
Is there any way to inject the ajax property to an existing field if I know the machine name of that field?
Is there any way to update an existing field state using ajax?
How can I do this programatically?

symfony2: how to set a user attribute (that is not in the form) after submitting a registration form?

I have added an attribute "color" the the User class, so when a user is registered I want a random color is assigned to this user.
How to do this smartly?
Set it in the User class constructor.
You can find a good example of setting default values for a new user in the FOSUserBundle's User constructor.
One of the advantages of this approach is that you don't depend on a persistence layer events and it works without a persistence layer at all.
I would add a lifecycle event in the User entity, a prePersist event.
Define in your user class the setRandomColor method, which set a color attribute of your User randomly.
Then, add it in your doctrine entity config as a prePersist event.
lifecycleCallbacks:
prePersist: [ setRandomColor ]
if you need your user color during a single session you can define an attribute for the user doing this:
$this->getUser()->setAttribute('attr-name',$attr-value);
and get that attribute with:
$this->getUser()->getAttribute('attr-name');
but, if you want to mantain the attribute as if it was an attribute in the user's table
you can
(obviously) update your schema and add the field in the table
get the color using a hash function over the primary key of the user's table.
Good luck!

How can I use current user (default membership) as a data field in DetailsView?

I am new to asp.net. I have a details view control on my page. I use linq to sql. My details view is an admin panel for data entry page. So some members will enter some news to my database. I want to use "Writer" Data Field to be filled automaticly with the current logged user. How can I do that?
Thanks
You will simply need to inject the username into the field at some point.
There is not a point-n-click drag-n-drop solution to this case, and there are many ways to accomplish this and to go into further detail is likely not necessary.
Just get the value into the textbox or field as the page is served where L2S can pick it up on the postback.

Resources