How can I update a field in Orchard via code - orchardcms

I'd created a content part "CompanyPart" which has a text field called "CompanyName". And added this content part to a content type Called "Company".
How Can I edit the value of the "CompanyName" field for a specific company via code. Or how Can I create a new Company with the company name set to "Company 1"

Related

Is there a way to connect a contact's category to their roles?

I am setting up a company for lead nurturing and marketing automation and I'm in the process of scrubbing up all of the contacts, customers, and leads. The way that we are using NetSuite right now, we don't have any need for a separate contact category and role.
So I want to set up a script to connect the category and role fields, or have the role field always copy what's in the category field.
Is there any way to achieve this?
The "Contact Category" and "Contact Role" fields in NetSuite are two different CRM list fields. Which means that:
In order to create a new "Contact Category", navigate to: Setup -->
Sales --> CRM Lists --> New --> Contact Category
And In order to create a new "Contact Role", navigate to: Setup -->
Sales --> CRM Lists --> New --> Contact Role
And because they are two different list fields, you need to have a 1 to 1 link of both these list values before populating it in your entity record.
One efficient way to do it would be by using a custom record as a reference. Please follow the below procedure to achieve the same:
Create a "Custom Record" titled "Contact Category & Roles" [or any appropriate name] with two fields in it: Contact Category (list/record of contact category) and Contact Role (list/record of contact role)
Now create each of these "Contact Category & Roles" custom record. For every record, select the Contact Category and the corresponding Contact Role.
Hence, in this way you will now have a list of this custom record that gives the Contact Category and its corresponding Contact Role.
This custom record can now be used as a reference in scripts.
For new records that are created, have a client script deployed. And in the "fieldChanged()" event of the script, write the logic to populate the role field based on what the category field is selected. [So here, when the category field is selected, reference the custom record and see if the category field has a corresponding role value and set it accordingly]
And since you are doing a scrub of already existing records, you can achieve the same by writing the above logic (point 5) in a schedule or map/reduce script (i.e by loading each record, getting the category value, referencing the custom record and getting the corresponding role and setting the role value).
Additional Note: If the Category values need to be cleaned up, a csv import could be done to achieve the same. You can then run the schedule script to set the role values.

Using the "Additional Fields" added to an external data column in a CQWP

I have a Custom List that I have setup with a column called "Name" which uses the External Data Type. It is a simple list that returns only one item from my external SQL table which the user selects in Sharepoint via the dropdown.
When I setup the "Name" column as "External Data" I selected additional fields to display by checking their names. For example I selected a column in my external data table called "CMF_CLIENT".
In the list all the data appears just fine including the "additional fields" that I selected. The header shows "Name" and then "Name:CMF_CLIENT" with the appropriate data listed below.
I have successfully configured the CQWP and can return the data in the column "Name" from that list (by using "Name [Custom Columns];" but what I would like to do is also include the "additional field" (CMF_CLIENT) as well. I've tried referencing it in the CQWP like "Name:CMF_CLIENT" as it appears in the list and several variations but I get the error that it "does not exist"...
Is there a way to actually query those additional fields into a CQWP or am I barking up the wrong tree?
Thanks in advance.
After continuing to play with it I finally figured it out.
One I was using a reserved name (bad practice). I changed the name to "Project Name", refreshed the list and then used
"Project Name: CMF_CLIENT" and it worked. Notice the space in between the : and the CMF_CLIENT.
Love it when you can answer your own question but it's here for reference!

how to get a userIds or users associated with particular assets category

If I create a new category it will store in AssestCategory table.At the same time entry should be in AssestEntry table also.For mapping between these two tables we have AssestEntries_AssestCategories table.How to achieve above thing by programmatically because for mapping table I didn't get any API.by these tables shall I get userIds associated with particular category. Or let me know is there any other way.
A new entry stored in AssetCategory when a category is created for a topic in site.
For example, Create a category named "Test Category" in site. You will see an entry in AssetCategory table. But there will not be any entry get stored to AssetEntries_AssetCategories table.
When the category is associated with some data item, then its association is stored in AssetEntries_AssetCategories table.
For example, When you create a bookmark with "Test Category" selected, then a new entry stores in AssetEntries_AssetCategories table.
entryId in AssetEntries_AssetCategories represents the corresponding entry for AssetEntry table.
In liferay Asset framework, liferay-ui:asset-categories-selector tag can be used to provide Asset category selection.
Please refer below links for details of liferay asset framework and to implement the same for a custom resource.
https://www.liferay.com/en_GB/documentation/liferay-portal/6.2/development/-/ai/asset-framework-liferay-portal-6-2-dev-guide-06-en
https://dev.liferay.com/develop/learning-paths/-/knowledge_base/6-2/enabling-assets-at-the-service-layer

SharePoint 2010: How do you reference the "Name" field when creating a lookup to a document library based on a document set?

I'm modifying the properties form of a SharePoint list that requires the user to select one or more items via a lookup to a document set. The document set library has a "Name" field which I cannot select as a field in my form's lookup properties.
The document set, of course, is a collection of documents grouped together with a common name, workflows, and metadata. The "name" I'm trying to display in my lookup list is set by the end user, but is inaccessible to me. Ideally, when someone is viewing an item in my SharePoint list (the one I'm trying to link from) and they see an associated document set item, they would be able to click on the name and it will take them to that element within the document set.
Any ideas?
Okay, I got around this issue by creating a new workflow that fires any time a record is modified. This workflow sets a new text field to the value in the Name field. To apply this to existing records, I created a new checkbox field named "Fire Workflow", then went to the Datasheet view and checked that checkbox for all of the records. This forced the workflow to fire on each record and update the new text field.
Now I just reference this new text field for the lookup in my other library. All is good!

Content type with workflow and lookup column

I have a requirment where I want to upload a document based on category and subcategory. I have added this columns as an lookup column which pulls data from category and subcategory list. Now want the document should be passed from series of approval so I have attached SharePoint out of the box Approval workflow to this document library.
Now I want to create a content type which contains these two lookup column and approval workflow. So that I can user these setting for rest of the document library.
Can any one tell me how to create a content type with workflow and lookup column.
Thanks in advance
Sachin
For an advance notice, if you associate a workflow with a document library, then all content types associated with that library will be able to utilize that workflow within that library. So you don't necessarily need to associate a workflow to a content type if it is already associated with the target list.
In no situation can you associate a workflow with a content type on creating the content type. Whether by object model or by UI, you have to add the workflow association after the content type has been fully created. Lookup columns can be associated with content type on creation, but only through the object model. Using the UI, you'll have to add it after creation, just like workflows.
To create a new content type in general, go to Site Settings, pick Site Content Types, and click the Create button in the toolbar. Fill out the form as you find it fit. Now, you can add the workflow association and lookup columns before or after you associate the content type with the list (depending on whether you want the workflow and lookups to be available on all lists that the content type is added to, or just the one document library). The process is the same either way, just a different place.
To add the content type to your document library, navigate to your document library and pick Document Library Settings from the Settings toolbar section. First you'll need to enable content type management if it isn't already by picking Advanced Settings, choosing Yes for "Allow management of content types", and clicking OK. Now, under the section of Content Types you can "Add from existing content types" to select the new content type you made, and click OK to confirm.
To associate the workflow and the lookup column with the content type, you need to modify the content type settings. Pick the content type from the list of content types (whether you are in the Site Content Types list or the content types list for the document library). You can associate the workflow by clicking "Workflow settings" on the content type page and choosing to add a new workflow. You can associate the Lookup column by picking "Add from existing site (or list) columns" and choosing to add the category and subcategory lookup you created earlier. Once complete, you'll now have a content type that is associated with a workflow and has the specified lookup.

Resources