How to create new JSONAction in Liferay 7 - liferay

I would like to create a new JSON Action, similar to GetLayoutsAction but returning list of defined forms. How can I do this?

Related

How to create category and sub category programmatically in Shopware 6

I am trying to create categories and sub-categories pro-grammatically in Shopware 6.
I looked at the entity class of Shopware\Core\Content\Category\CategoryEntity but i'm not sure that whether this class will work or not? I do not want to assign any products.
Does any one know how to create categories in the Shopware 6?
Creating categories is like creating any other entity through their repository. You can get the category repository from $this->container->get('category.repository') and then simply call the ->create method on the repository object.
You will have to pass the data array to it as the first argument and a context as the second argument. What data you need to pass in the array you can check out the CategoryEntity class (which you have correctly identified already).

Automapper to update an existing object as opposed to creating a new one [duplicate]

This question already has answers here:
Automapper: Update property values without creating a new object
(4 answers)
Closed 4 years ago.
Is there any way to use Automapper 5.1.1 to update an existing object as opposed to creating a new one.
For example we have a Customer entity and a CustomerViewModel. We would like to update an existing Customer with the CustomerViewModel field values.
Would greatly appreciate your assistance.
It is not adviced to use Automapper to map a model to your Entity. Dependencies or Informations can be overwritten if it isn't used wisely.
But to use it as you want, you only need to create a map from your Model to your Entity and then call
Mapper.Map(myModel, myEntity);
The mapping to entity Problem
I guess you use a ORM like NHibernate or EF, then your Entites are Proxies, where references are proxies too and so on. Now lets imagine you have an ASP.NET MVC Project and you map your Entity to your ViewModel. You show your Model in your View as a form, but you only show the properties that you need in your view, not all that are set in your ViewModel. Then the user sends the Form back to you and your Controller gets the ViewModel back, but this time not all Properties are set, because your View only knew the ones that were shown. If you map your ViewModel back to your entity, all unitialized properties are in there default state and will overwrite the valid data f rom your entity.
Another Problem is, that AutoMapper uses Reflections to set the Properties. Normally the right to exist for an ORM is the possibility to easy implement an DomainLayer. The DomainLayer has some Validations, Calculation... on the Entity itself. If now the Properties set with Reflection it would ignore the Business logic and no Validation, Calculations.... would be executed.
So my advice is, Don't map to Entities ;)

Load an existing field in a custom module

In drupal 8 (or 7?), is it possible to load programmatically an existing field ?
I mean :
from the drupal administration, I create a new custom content type with some fields. This fields have an unique machine name. I want create a form from a custom module. In this form, I want "load" the existing fields created in the custom content.
So, is it possible to load existing fields in a .php module ?
In case you want to build a custom form with field values of a created node, you can load the node programmatically with Node::load($nid) and put the the values in the render array. This way you need a predefined node you created yourself, because you call it using it's ID.

Alfresco - Search Workflow with like cluase (or contains!)

I've developed a simple webscript that accepts in input some paramenters and returns a list of workflows that matches the conditions. This is a simplified version:
WorkflowInstanceQuery workflowInstanceQuery = new WorkflowInstanceQuery();
Map<QName, Object> filters = new HashMap<QName, Object>(9);
if (req.getParameter(MY_PARAM) != null)
filters.put(QNAME_MYPROP, req.getParameter(MY_PARAM));
workflowInstanceQuery.setCustomProps(filters);
List<WorkflowInstance> workflows = new ArrayList<WorkflowInstance>();
workflows.addAll(workflowService.getWorkflows(workflowInstanceQuery));
List<Map<String, Object>> results = new ArrayList<Map<String, Object>>(workflows.size());
for (WorkflowInstance workflow : workflows)
{
results.add(buildSimple(workflow));
}
This is working perfectly, but now i'd like to have as a result all the workflows that match in like or contains the property in input.
For example if the property in input is valued "hello" i would like to have in output of the webscript the workflows that have that property with values such as "hello" or "hello Dear" or "Say hello" and so on...
This is actually working with search for content in Advanced Search of Alfresco Share...how to implement with WorkflowInstanceQuery?!
Alfresco's ActivitiWorkflowEngine class uses Activiti's HistoricProcessInstanceQuery for the search and it is using "variableValueEquals" method to add the custom properties so it will never behave as a "LIKE" clause.
There are two things which you need to consider here.Workflow Model and Content Model.You need to understand both of the things here.Whatever properties are created in content model are stored with documents and not with workflows.Workflows are having task model associated with it.So logical its going to difficult to find filter workflows based on properties of document.Because there is no association between them, unless and until you have explicitly created it.
If you want to filter based on properties than it should exist in workflow model associated with workflow task.That too you have to filter based on task of workflows.Because each task will have its own property.
Have you tried putting wildcards for your filters parameter?
filters.put(QNAME_MYPROP, "*"+req.getParameter(MY_PARAM)+"*");

How to get all the custom fields values from dynamics crm 11?

i'm using OrganizationServiceProxy to get all the fields values from the CRM server.But its returning only used fields values.It doesnt have unused custom field values. :( . how to get all the custom fields values from crm2011.?
using (ServiceContext svcContext = new ServiceContext(cons.createProxy(logfilePath)))
{
var contactlist =(from a in svcContext.ContactSet
where a.new_proid.Equals(contact_id)
select a);
}
"new_proid" is custom fields.Its not available but all the other defaults values is available.
In your code you are using Early Bound, this means you generated the helper classes using crmsvcutil.exe from the SDK.
If you don't see some fields inside the Contact class it's because the field was created after the classes were generated.
You need to generate again the helper classes and include the new version inside your project.

Resources