Maximo Anywhere 7.5.2, In WO Listing page to display value and description in same column - maximo-anywhere

How to Display value and description in same column in WO Listing page,
Example: ZIST- Device Installation for OPC and LPC

You have to add a new local Attribute to your Workorder Resource, and I would recommend that you populate it in the onInitialize() method of that object. Then add that local attribute to the workorder list like any other attribute. Take a look at how we do this with assetnum and assetdescription in our existing code.
onInitialize : function(workOrder) {
workOrder.set("locationdesc", workOrder.get('maxlocationdesc'));
if(workOrder.get('assetdesc')==null){
workOrder.set("assetnumanddescription",'');
}
workOrder.set("assetdesc", workOrder.get('maxassetdesc'));
if(workOrder.get('locationdesc')==null){
workOrder.set("locationanddescription",'');
}
fieldUtil.initCompositeField("wonum", "description", "wonumanddescription", workOrder);
fieldUtil.initCompositeField("asset", "assetdesc", "assetnumanddescription", workOrder);
fieldUtil.initCompositeField("location", "locationdesc", "locationanddescription", workOrder);

Related

2sxc Prefill datetime value in Manage Content Data

I created a Entity in Content-Types and Data and this entity have a field that is a datetime
When I click in the Plus button (+) I want to hide the field from user (this I got) and that default value be the current date (to be filled behind the scene)
Is there a way to achieve this ?
I read about prefill but I dont got how to do that with the default "Manage Content / Data"
I´m using 2sxc 10.24.0
Welcome to StackOverflow, #Alexandre ;)
The special buttons can only be done in the view. The internal manage-data doesn't provide options to customize. You can set default texts, but there is currently no mechanism to provide tokens, JS or something to get dynamic values as an initial value from the normal Admin-dialogs.
I got if I create a view and then use
#Edit.Toolbar(toolbar: new object[] { new { command = new { action = "new", contentType = "Articles", prefill = new { CreationDate = DateTime.Now } }}}
I believe that to do that in Manage Content / Data will be need to modify the "view" from the 2sxc

Magnolia get content from children page in freetext

I have a tree structure and want to use this as a category based faq.
I know there is a categorization module, but i want to use a file tree structure.
so i had the following:
faq
- first category
- first entry
- second entry
- second category
- first entry
...
each page has an dialog with an headline and a description. thats the content i want to get for each page.
so currently i get the current page, and loop through the childpages
[#local currentPage=cmsfn.page(content) /]
[#local pageChildren = cmsfn.children(currentPage, "mgnl:page")]
[#list pageChildren as page ]
{
"category": "${page.title}",
[#local pageContent = cmsfn.contentById(page)]
"headline": "${pageContent.headline!?json_string}",
"description": "${pageContent.description!?json_string}"
} [#if page?has_next],[/#if]
[/#list]
Now i get the category (the page title) for each entry. Thats fine. But headline and description are not filled.
I know, page is a node. page is the page and can access each page property (title, template).
I didn't find anything to get the content from a page via cmsfn. There are methods for contentById, contentByPath and also page() to get the page for a content.
But how i can get the content, from a page?
Update:
I made big step.
I get my pageContent from contentByPath, and use here the path of the page.
After this, i convert this to an JCR Node.
[#local pageContent = cmsfn.contentByPath(page.#path)]
[#local jcr = cmsfn.asJCRNode(pageContent)]
Now dumping shows my jcr.
Node (/my-website/faqs/kategorie1/question1)
footer = Node (/my-website/faqs/kategorie1/question1/footer)
mgnl:activationStatus = true (Boolean)
[...]
jcr:uuid = "a09d13da-3549-4b2a-8609-3b635e6f1c59" (String)
layers = Node (/my-website/faqs/kategorie1/question1/layers)
mgnl:activationStatus = true (Boolean)
[...]
jcr:uuid = "08b52c64-7327-4300-884c-047e42f560d0" (String)
overlays = Node (/my-website/faqs/kategorie1/question1/overlays)
mgnl:activationStatus = true (Boolean)
[...]
jcr:uuid = "9a78479b-0d25-4acf-9554-b9d626a7cc61" (String)
content = Node (/my-website/faqs/kategorie1/question1/content)
0 = Node (/my-website/faqs/kategorie1/question1/content/0)
description = "something" (String)
headline = "my example" (String)
mgnl:activationStatus = true (Boolean)
mgnl:created = Jul 24, 2019 11:20:40 AM UTC (Date)
What i really need, is here the content node, and the description and the headline.
But how to access this, and are there better methods to get this content?
You've already gotten the title of a page and any other property on the page node behaves just same as the title property. Hence, page.description will give you the description property of the given page node/object.
Let's also clarify what #contentById() method does. It is responsible to fetch a node by its identifier and returns a ContentMap e.g.
ContentMap (think as a Node object but mere Map) contentById(String identifierOfRequestedNode)
Update:
Via contentById method, you can directly access description and name, you do not need to convert it to the Node object.
E.g.
pageContent.description
pageContent.name
Hope that helps,
Cheers,

How to dynamically load image into picturebox in fast report?

I have a table in Sql that has 2 columns containing header and address of images that related to that header like below:
Header address
194003 ~/viewerImages/1903-01-1-5-0-6-00143.jpg
194003 ~/viewerImages/1903-01-1-5-0-6-00161.jpg
194003 ~/viewerImages/1903-01-1-5-0-6-00190.jpg
194012 ~/viewerImages/1903-01-1-5-0-6-00143.jpg
194012 ~/viewerImages/1903-01-1-5-0-7-00141.jpg
194012 ~/viewerImages/1903-01-1-5-0-7-00160.jpg
194015 ~/viewerImages/1903-01-1-5-0-7-00180.jpg
194015 ~/viewerImages/1903-01-1-5-0-8-00159.jpg
194015 ~/viewerImages/1903-01-1-5-0-8-00184.jpg
I want to load these images dynamically in fastreport for each header.
what should I do?
One solution is to create an objet with some properties that are the images to load (image1, image2, image3). You also add more properties with the data that you want to print in the report.
Then, you can load the information in the object dinamically and after send the object to the report, so Fast Reports will print the information you are loading in the object. In this way you can do wharever you want dinamically.
For image properties, you can use Image or byte[] type.
To create the report:
var report = new Report();
report.Load(Constants.Paths.ReportFolder + "Return.frx");
report.RegisterData(myObject, "Name");
report.Design(); // if you want to open the designer before to print
report.Show();
Note: The object to register must be a collection of objects. In this case myObject would be a List. If you want to register a single object, you can do it in this way:
report.RegisterData(new List{ myObject }), "Name");
In the designer you can access all the properties.

Getting the values from a repeated Embedded Schema using TOM.NET API in an event handler in SDL Tridion 2011 SP1

I am working on the Event Handler for saving a component.
My objective is to perform some validations when the user creates and component based on a schema.
I have a schema with the name "Employee".
Employee has an embedded schema with the name "Experience" and it is multivalued.
Experience has 3 fields.
Role : Drop down with the values Manager, Lead.
Company: Text field
Years: Text field
When the user enters some data in these fields, I want to do some validations before save.
The high level design would look like this.
Load the instance of the Component
Navigate to embedded field "Experience"
For every "Experience". I need to get the value of the "Role", and check that appropriate value is entered in other two fields(By writing Component Save event)
For( all the repeated "Experience")
{
If (Role=="Manager")
check the values in the other two fields and do some validation
If (Role=="Lead")
check the values in the other two fields and do some validation
}
I am stuck at extracting the value and Names of subfields at the embeddded field.
I have tried:
Tridion.ContentManager.Session mySession = sourcecomp.Session;
Schema schema= sourcecomp.Schema;
if(schema.Title.Equals("Employee"))
{
var compFields = new ItemFields(sourcecomp.Content, sourcecomp.Schema);
var embeddefield = (EmbeddedSchemaField)compFields["Experience"];
var embeddedfields = (IList<EmbeddedSchemaField>)embeddefield.Values;
foreach(var a in embeddedfields)
{
if(a.Name.Equals("Role"))
{
string value=a.Value.ToString();
}
}
}
Actually I am stuck how to retrieve the values in the other fields at the same time.
Can any one explain how it can be done?
What you need to understand on a EmbeddedSchemaField class is that it represents both a schema and a field (as the name implies...)
I always find it helpful to look at the source XML of the component when writing code that targets its fields, you get a good visual representation of what your classes must do. If you look at a component XML like this:
<Content>
<Title>Some Title</Title>
<Body>
<ParagraphTitle>Title 1</ParagraphTitle>
<ParagraphContent>Some Content</ParagraphContent>
</Body>
<Body>
<ParagraphTitle>Title 2</ParagraphTitle>
<ParagraphContent>Some more Content</ParagraphContent>
</Body>
</Content>
Body is your embedded Schema field, which is multivalued, and contains 2 single-valued fields within it.
Addressing these fields in TOM.NET then:
// The Component
Component c = (Component)engine.GetObject(package.GetByName(Package.ComponentName));
// The collection of fields in this component
ItemFields content = new ItemFields(c.Content, c.Schema);
// The Title field:
TextField contentTitle = (TextField)content["Title"];
// contentTitle.Value = "Some Title"
// Get the Embedded Schema Field "Body"
EmbeddedSchemaField body = (EmbeddedSchemaField)content["Body"];
// body.Value is NOT a field, it's a collection of fields.
// Since this happens to be a multi-valued field, we'll use body.Values
foreach(ItemFields bodyFields in body.Values)
{
SingleLineTextField bodyParagraphTitle = (SingleLineTextField)bodyFields["ParagraphTitle"];
XhtmlField bodyParagraphContent = (XhtmlField) bodyFields["ParagraphContent"];
}
Hope this gets you started.

How to get Tridion item ID after created using Core Service

I am creating a new item using the Core Service in this post. However, the URI of the newly created item is tcm:0-0-0 instead of the actual TCM URI. the Title property is correct (and not New Component) but the WebDav path returns 'New Component' while .
What is the best way to get the URI of my newly created item?
client.Create(newComponent, null);
string newItemUri = newComponent.Id; // returns tcm:0-0-0
string webDavUrl = newComponent.LocationInfo.WebDavUrl; // returns New%20Component
string title = newComponent.Title; // correct
Second parameter of Create method are ReadOptions. They are used to specify how the item will be read back. In your example you have it set to null, meaning you will not read it back. What you should do is set ReadOptions and assign item read back to a variable, like this:
newComponent = (ComponentData) client.Create(newComponent, new ReadOptions());
Check out Ryan's code at http://blog.building-blocks.com/uploading-images-using-the-core-service-in-sdl-tridion-2011. He uses client.Save to get the saved Component, from which he's able to access the ID.

Resources