I have a XML file which I have to convert in CSV file and then attach in Work-Object?
I already tried by writing an activity and use pxConvertResultsToCSV activity and then try to attach file using Link Object method but by this all the result would come in a single row.
Few steps to be followed...
1) Parse the XML using activity method Apply-Parse-XML.
You will get the XML data in a PageList.
2) Now create on Rule-Obj-Html rule. In the code part create on table
<table border="1">
<pega:forEach name="YourPageListPage.PageList"> // --> the pagelist in which got the info from xml.
<tr>
<TD>
<pega:reference name="$THIS.COLUMN1"/> // --> property name
</TD>
<TD>
<pega:reference name="$THIS.COLUMN2"/> // --> property name 2
</TD>
</tr>
</pega:forEach>
</table>
3) Now using Property-Set-HTML get the stream of your html rule in some param variable(for example param.pyFileData)
Also create one local variable as strFileData.
Decode the stream Using Java step. And use this code.
String atr = (String)tools.getParameterPage().getParameterValue("pyFileData");
byte[] byteArray=(byte[])atr.getBytes();
//encode the byte array into Base64.
strFileData = Base64Util.encodeToString(byteArray); // strFileData is local variable mentioned in activity.
4) Now create a page of class Data-WorkAttach-File and set following properties on that page.
.pxRefObjectKey --> pzinskey of work object
.pxAttachKey --> any key, maybe current date time
.pyAttachStream --> your stream which you got from 3rd step (local.strFileData )
.pyNote --> any note
.pxAttachName --> "filename.csv"
Rest I guess already know..
Save this page using Obj-Save
5) Use Link-Objects to attach your attachment page to work object.
Thats it.
Related
I have a JWT that I want to display its contents after signature validation. so, I verify the signature like this:
var verified = JWT.Decode(token, publicKey);
In this case, verified is a string containing the JSON payload, looks something like this:
{"sub":"211668914321303","aud":"MUSCA","ver":"1.0.0","nbf":1544459925,"iss":"blimp gmbh","rle":"MUSCA_ACCESS","prm":"This chunk is bound to the something for blimp gmbh","exp":4703150773,"iat":1544459925,"jti":"46"}
now to view this on a page in form of a table, it's easier to send it as a JSON, and loop on its Type and Value, like this:
var verifiedJSON = JsonConvert.DeserializeObject(verified); //convert to JSON
ViewBag.payload = verifiedJSON
in my view, I loop on the ViewBag like this
<table class="table-bordered table-responsive">
#foreach (var line in ViewBag.payload)
{
<tr>
<td>#line.Type</td>
<td>#line.Value</td>
</tr>
}
I would expect that the table will show type and value in columns, but instead of the type(key), I get the word Property, with the expected value in each row!
I tried to display the JSON below the table to see if it came with "property" in the key fields, but it viewed with the correct key names. am I missing something or why can't I get the table to view the keys correctly?
I found the issue thanks to jabberwocky
I copied a table that was looping on an IEnumerable, and changed the variable which is a JSON, and by referring to Json.NET Documentation, I found out that the Key is not called Key or Type. It is called Name
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.
For the life of me I cannot figure out why this works. I'm simply calling some data via link and passing it on to the view. It works when I passe the data directly like this:
var invoices = (
from s in navdb.Sales_Invoice_Header
where s.Salesperson_Code == repCode
where s.Posting_Date > date
select s
).ToList();
But when I create an anonymous type on the fly it does not, like this:
var invoices = (
from s in navdb.Sales_Invoice_Header
where s.Salesperson_Code == repCode
where s.Posting_Date > date
select new {
s.No_,
s.Bill_to_Customer_No_,
s.Bill_to_Name,
s.Salesperson_Code
}
).ToList();
when accessing it like this after:
<table>
#foreach (var invoice in ViewBag.invoices)
{
<tr>
<td>#invoice.No_</td>
<td>#invoice.Bill_to_Customer_No_</td>
<td>#invoice.Bill_to_Name</td>
<td>#invoice.Salesperson_Code</td>
</tr>
}
</table>
I just get an: 'object' does not contain a definition for 'No_'
I've tried adding No_ = s.No_ and so forth, that does not help either. What am I doing wrong?
Duplicate question here: Dynamic Anonymous type in Razor causes RuntimeBinderException
The reason for this is that the anonymous type being passed in the
controller in internal, so it can only be accessed from within the
assembly in which it’s declared. Since views get compiled separately,
the dynamic binder complains that it can’t go over that assembly
boundary.
Basically, you can't bind against anonymous dynamic objects in this way. Define a specific class or struct to get around this.
In your first example, you're getting a List<whatever s is>, in your second example, you're getting a List<object>. And 'object' does not contain a definition for 'No_'
I implemented a ribbon tool bar button for Tridion 2011 SP1, which opens an aspx page and populates a drop down list based on a look-up component. The look-up component comprises of different embedded schemas. To filter out the values based on embedded schema name I need to get the Embedded schema field values of component creation page on button click in button JavaScript.
Because in my component creation page consists of multivalued Embedded schema field has the info, which helps look up value filtering process. I am unaware of the command need to be used for the requirement. I know about a command to get the complete component XML, that is: $display.getView().getItemFields().
To get the present RTF field content I am going for the command: target.editor.getHTML(). To get the complete set of Embedded schema field values only,
which command I need to use?
My sample component source:
<root>
<a>sample a</a>
<b>sample b</b>
<c>
<ca>ca 1</ca>
<cb>cb 1</cb>
<cc>cc 1</cc>
</c>
<c>
<ca>ca 2</ca>
<cb>cb 2</cb>
<cc>cc 2</cc>
</c>
<c>
<ca>ca 1</ca>
<cb>cb 1</cb>
<cc>cc 1</cc>
</c>
</root>
I don't think there are public API for that. But you could use component data xml and then parse it by yourself:
var item = $display.getItem();
var xml = item.getContent(); // OR $display.getView().getItemFields();
var xmlDoc = $xml.getNewXmlDocument(xml);
var schema = item.getSchema();
if(schema.isLoaded())
{
var xpath = "/custom:{0}/custom:embeddedFieldName".format(schema.getRootElementName());
var fields = $xml.selectNodes(xmlDoc, xpath, { custom: schema.getNamespaceUri() });
// loop fields and get values ...
}
JSTL Code:
<c:forEach var = "currentUser" items = "${users}">
<c:out value = "${currentUser.userName}" /></p>
<c:if test = "${!empty param.${currentUser.id}}">
<p>Details</p>
</c:if>
</c:forEach>
I have a list of user objects and i display all of their names. If one wants to see the details of any user a request is sent to a servlet which will return a Attribute with the name id and a DetailUser Object
Servlet:
req.setAttribute(currentUSer.getId, userDetails);
The problem is that, now if have to use the value of "id" in the if test not as a parameter, but a parameter name instead. I've tried that EL in EL expression but I am really sure that it isn't allowed. Any other suggestions?
It seems to me that you're making it more complex than it could be.I would simply do
req.setAttribute("userDetails", userDetails);
and, in the JSP, test if the current user's ID is the same as the one being detailed:
<c:if test="${userDetails.id == currentUser.id}">
<p>Details</p>
</c:if>
BTW, param.foo returns the value of a request parameter, not the value of a request attribute.
You could do what you wanted by using
<c:if test = "${!empty requestScope[currentUser.id]}">
The [] notation instead of the . operator is the way to pass a dynamic name rather than a static one.