Kentico 11 System Generated GUID - kentico

Using Kentico 11 (Portal engine)
I would like to add a GUID field to one of my pagetypes. I would like the system to generate the guid (I assume this is done via a macro?). Any idea what macro might do the trick? Any help is appreciated.

I do not believe there is a macro which will generate a new GUID for you. You'd have to create a custom macro method to do that for you. The macro you're using won't work because the document isn't created at the time the macro is accessed. AND it wouldn't be unique either.

I had the same issue... I just ended up fixing it directly in SQL by adding default value:
ALTER TABLE [SomeTableName] ADD CONSTRAINT [ContraintName] DEFAULT NEWID() FOR [ColumName];
This is your custom column so you can set the value to whatever your want. I dont see any other use for GUID macro although it is not complicated thing to do.

For others that stumble upon this question in need of an auto-populating unique identifier field, I chose to use existing macro functions to piece together a unique string. This was a more appealing solution than going down the build-your-own macro path.
Here is the macro I used in the Default value field:
{% String.FormatString("{0:yyyyMMddhhmmssfffff}", CurrentDateTime) + Math.GetRandomInt(10000, 99999) #%}
Here's an example value:
201912200958109206631318
No, it's not technically a GUID. It does the job, though.

Related

how do i correctly set up a parameterized information link in spotfire?

Also posted on super users:
I'm a spotfire novice trying to create a parameterized info link. Ultimate goal is to create a default template that may be customized to return specific rows in a very large table. I've not been able to cobble together enough information from online searches to get me from point A to Z.
Spotfire version is 7.11 on an Oracle 11.2 SE DB.
Currently I've got a date/time prompt in the info link that will be global to all users. What I need is to be able to further filter to 1 of 2 columns (one is real, the other a string) in order to minimize loading times. There are 17 other on-demand tables that are related to the main one. Limiting the initial query will greatly speed up performance.
In information designer for the information link, if I edit the SQL in the WHERE and explicitly define the value or string for the column, I get the rows I want. When I try to define it using an input parameter (?ParamName), I either get nothing when I reload or get asked to input a parameter "for testing".
Q1: In the document properties for the analysis, I've been adding in properties that I assume is supposed to get picked up by the query.
- What part do scripts play in passing this variable to the SQL?
- Do I just need to define a value for a property name or include a IronPython script? - If script is required, can I just define the parameter to pass?
Q2: In the info link SQL, what is the correct syntax for defining the parameter variable depending on the type (real v string)? If I use a string, I need to include LIKE in order to pick up the desired rows. If I use a real, is it possible to define it as a list of values?
Thanks in advance.
Though not exactly clear from your description, I think you should be able to accomplish your goals using the "Load on demand" dialog that is accessed either when you add your data table to your analysis, or subsequently using the Data Table Properties>Type of Data>Settings dialog.
Spotfire uses this dialog to dynamically modify your SQL. Thus, you do not need to explicitly include the LIKE statement in your SQL. Spotfire will add it in based on what you define in the On-Demand settings. For example, you could have an Input Field where you type a constraint that will be stored as a Document Property and then refer to that Document Property in your On-Demand settings to control the table loading.

Segmented Keys in ACUMATICA

I’ve created new Segmented Keys in ACUMATICA for use in a specific module. I would like to assign the Dimension name dynamically but I noticed it works only with hard code or name like [PXDimension(“VENDOR”)]
Also, I have some limitation to create an IF Conditional inside the customized field… it does not recognize the IF clause (see the image).
I would appreciate any suggestion how to solve this issue.
I haven't seen how your original attempt at PXDimension looked, but I'm going to take a guess and assume you tried to reference a new custom field contained in a setup table, something like:
[PXDimension(typeof(XXMySetup.usrMyCustomField))]
If that's indeed what you tried to do, one very important thing to do is to ensure that you have a view for your table in your graph, otherwise the attribute will not find the table and record in your cache. For instance:
public PXSetup<XXMySetup> XXMySetup;
Without this view declared in the graph, the dimension attribute will not work as expected. It would be nice if a clear exception was thrown in this case - I made the same mistake recently and it would have been helpful.

Why the OnWorkflowItemChanged is different between List and document library?

I am doing a workflow for a document library. I put a OnWorkflowItemChanged, and I want to get the value of the column which is changed. I use the workflowProperties.Item["name"] and use the afterProperties. But when I use the workflowProperties.Item["column name"], I still got the original value. When I use the afterProperties, it's NULL.
Then I make another workflow that is the same as above for a list. I can use the workflowProperties.Item["column name"] to get the new value in OnWorkflowItemChanged.
Has anyone come across this problem before? Can you give me some help?
The question seems to mix up Item with ExtendedProperties. As to why a difference is seen on a List/Document Lib, it might have something to do with versionining or perhaps the internal serialization is different. Anyway, some of my experience is outline below. I hope it may be of use:
Use the GUID (as a Guid object, not a string) to access the Before / After ExtendedProperties field. Using the Display Name in the ExtendedProperties will not work. The documentation on it is wrong. You can use SPList.Fields to go from Display Name to Column ID (Guid).
I bind all "Before" to MyWhatever_PreviousProperties and all "After" to MyWhatever_Properties, only accessing MyWhatever_[Previous]Properties after the appropriate event(s)).

I'm missing functionalities on SubSonic 3

I'm starting to do some test on SubSonic 3 and I'm missing some stuff.
1st: Where's the Table names constants? The place where we could ask for the same of a certain table using intelisense...
2nd: Same as the above but for the table columns... where are they?
This is very useful mostly when you need to pass those names as string... it you need to refactor your DB we don't need to look through all the code to find where was I using that column!! Once you re-generate the code the compiler tells you!
3rd: Now how can I perform an ExecuteReader on a certain table like I'm used to on 2.x through the Query object? I used this a lot for list where I really don't need the business objects (BO) overhead... When I needed a BO (for showing a grid row details) I create it from the row itself...
I'm using ActiveRecord btw...
Thanks guys!
Alex
1st: Where's the Table names constants? The place where we could ask for the same of a certain table using intelisense...
In Structs.tt find the following line of code at line 47:
<# foreach(var col in tbl.Columns){#>
Add the following code above it:
public static string TableName { get { return "<#=tbl.Name#>"; } }
Now you'll have a property that returns the name of the table.
2nd: Same as the above but for the table columns... where are they?
In the generated Structs.cs file, this is included in the 3.0.0.3 version
3rd: Now how can I perform an ExecuteReader on a certain table like I'm used to on 2.x through the Query object? I used this a lot for list where I really don't need the business objects (BO) overhead... When I needed a BO (for showing a grid row details) I create it from the row itself...
If you're using SqlQuery object you can call ExecuteReader on it. Alternatively you can use Linq syntax to generate return custom shaped objects and they'll get mapped automatically.
1st and 2nd: It's not implemented in the default tt-files.
A similiar question:
SubSonic 3 Simple Query Tool
Problem is that's not a correct implementation if you want the 2.x way - the XColumn properties used to be column objects and not string constants, those were found under the Columns struct. So I hope that check-in will not be accepted and that someone will 2.x-ify it correctly.
Anyway as you can see it seems pretty easy to fix it on your own.

How to create a lookup column that targets a Doc Lib and uses the 'Name' of the document?

How do you create a lookup column to a Document Library that uses the 'Name' of the document as the lookup value?
I found a blog post that recommends adding another custom field like "FileName" and then using a item reciever to populate the custom field with the value from the Name field but that seems cheesy.
Link to the blog in case people are interested:
http://blogs.msdn.com/pranab/archive/2008/01/08/sharepoint-2007-moss-wss-issue-with-lookup-column-to-doc-lib-name-field.aspx
I've got a bunch of custom document content types that I dont want to clutter with a work around that should really work anyway.
I created a one step workflow to set the title from the name, fired on modify and created. Seems to work and took seconds to create.
One way you can do this (although not the easiest way) is by creating a custom field type that extends the SPFieldLookup class. SharePoint's field editor for Lookup fields purposefully hides any columns types that aren't supported by Lookup fields, but you can create a field editor for your custom field type that shows them.
However, I have created a Lookup column that points to a Name column in a Document Library before, and it probably doesn't work like you'd expect. While the value stored in the lookup column is valid, it doesn't show up right in List view or on the View Properties form.
The solution you posted may actually be the best way to handle this. Lookup fields require some kludges if you want to handle more complex scenarios, but that's because they're not meant to provide the same functionality as a foreign key relationship in a database.
Coding in any form always scares me. So Here's what I did: I simply renamed the Stupid "Title" Field to something else, say "Keywords", since you cant do anything with that field: cant even make it mandatory.
Then I created another Single line field called "Title" and used this field for the Lookups
Well there is a simple solution to that and in might work in some case.
In the nutshell if you make the Title field Mandatory, this will force the user to enter a title. In that manner we can use title field as a lookup field.
Now How to do that?
One you are done create a document library go to the library setting. Select Advance Setting and Select Yes for the option "Allow management of content types?".
Then go back to the Library setting and Under content types select the "Document" Content type. THen Select Title Column and then Select "Required (Must contain information)" and say OK.
Now try uploading a document to this document library. You will see Title field in the form.
Hope this helps
Cheers
Vaqar
You have to add the field as XML with the ShowField as 'FileLeafRef'
var XmlFieldDefinition = "<Field DisplayName='myLookupColumn' Type='LookupMulti' StaticName='myLookupColumn' Name='myLookupColumn' Required='FALSE' List='THE LOOKUP ID HERE' WebId='THE WEB ID HERE' UnlimitedLengthInDocumentLibrary='TRUE' Mult='TRUE' Sortable='FALSE' ShowField='FileLeafRef' />"
Field fld = fieldCollection.AddFieldAsXml(XmlFieldDefinition, true, AddFieldOptions.DefaultValue);
ClientContext.Load(fld);
ClientContext.ExecuteQuery();

Resources