Strapi v4 change image alt/caption from string to text without losing the data? - strapi

Using default strapi media/image. After setting long caption/alt text I get this error:
error: update "files" set "name" = $1, "caption" = $2, "updated_by_id" = $3, "alternative_text" = $4, "updated_at" = $5 where ("id" = $6) - value too long for type character varying(255)
Pretty sure it's due to database trying to save it as a string field instead of text.
Can I change this without creating a new model?

Related

Retrieve Umbraco Tags datatype field in a LINQ query

I want to insert the values of an Umbraco.Tags datatype field into my razor output for each record from a LINQ query of my content. I'm having trouble finding the right syntax. I realize it should be a string array but everything I have tried fails.
In the page for the individual content I have been able to use the following where the content field is name "Tags".
var tags = CurrentPage.Tags;
The LINQ query is complex, but I am simply trying to add the tags to the output so that I can search inside the page for specific records on the client side. I have removed most of the query to make it easier to read.
var products = Model.Content.Site().Descendants<PenList>().First().Children("penProduct")
.Where(x => x.IsVisible())
.OfType<PenProduct>()
.Select(x => new ProductSearchResultItem() {
FilterText = x.ProductName + " " + x.ProductDescription.ToString() + " " + x.CompanyName.NullSafeToString() + " " + x.ProductType.ToString()
+ " " + (x.Parent.GetProperty("tags") != null ? x.Parent.GetProperty("tags").Value : string.Empty)})
I have also tried just getting x.Tags or x.GetProperty("tags") with no success. Any suggestions would be appreciated.
Is the tags property on the penProduct doc type or the penList? It looks like you're looking for it on the penList.
But I would think it would behave like any other string. I don't normally use typed modals, but to get a list of the tag values in my views I use:
var tags = Model.Content.GetPropertyValue<string>("tags", "").Split(',');
Since the field is actually a string array I had to use the following code to get the property as a string array generic otherwise it would return the text of the type "System.String[]".
x.GetPropertyValue<string[]>("tags")

Laravel 5: can't set date from string

On my db migration i have a "dob" field:
$table->date('DOB')->nullable();
I have a string representing a date: "12/12/1960" in the input. I tested "dob" and the content is there. But when I try to set it to the "dob" field in the database..
$member->DOB = date('m/d/Y',Request::input('dob'));
The datebase field becomes 0000-00-00
What am I doing wrong?
The database most likely wants it in YYYY-MM-DD format. So just changing the format should work. But to get from 12/12/1960 to there, you need to parse it.
$oldDateString = '12/12/1960';
$newDateString = DateTime::createFromFormat('m/d/Y', $oldDateString)->format('Y-m-d');
Look at definition
string date ( string format [, int timestamp] )
Second parameter is timestamp, not string
Use DateTime PHP5 functions or Laravel Carbon
E.g. date_create_from_format('m/d/Y', Request::input('dob'))
->format('Y-m-d H:i:s');

Format a FTQuery to find a field containing a role

I need to find all the documents in a database that the field wfsCurrApp contains a given role. in the search bar I entered field WFSCurrApp contains [Finance] but I get the error that the query is not understandable. If I change it to field WFSCurrApp contains "[Finance]" the query runs but returns nothing.
What I'm ultimately trying to get done is something like this because the user may possess several roles in the target database I believe the issue is the [] as that is used to delimit dates, but ????:
var uRoles = thisDB.queryAccessRoles( context.getUser().getDistinguishedName());
var userRoles:String = "";
var it:java.util.Iterator = uRoles.iterator();
while (it.hasNext()){
var thisRole = it.next()
if (userRoles == "") {
userRoles = thisRole
}else{
userRoles = userRoles + " OR " + thisRole;
}
}
tmpArray[cTerms++] = "(FIELD WFSCurrApp CONTAINS (\"" + userRoles + "\"))";
Edited:
tmpArray has this in it
(FIELD WFSCurrApp CONTAINS ("[Finance]")) when the user has a single role and
(FIELD WFSCurrApp CONTAINS ("[Finance]" OR "[WFSAdmin]")) if the user has multiple roles. Neither of these return any documents that I know have the role [Finance] in the Current Approvers field WFSCurrApp.
The query has a number of other tags so tmpArray is split and each element is seperated with an "OR". This is the final query
(FIELD WFSCurrApp CONTAINS "Barney Rubble/Workflo Systems") OR (FIELD WFSCurrApp CONTAINS ("[Finance]"))
the query returns the documents where WFSCurrApp contains Barney but not the ones where Barney's role is [Finance] and there are some that Barney is not in the current approvers but he possess the role [Finance] and that role is in the Current Approvers.
The query returns without error and returns the documents where Barney is listed in the Current Approvers so there are no errors raised, just does not find the matching role.
Started Working correctly so guess it might have been an index update issue

"Query is not understandable" - Full text searching where field types have changed

A client have a long lived IBM Notes application where someone along the line changed the type of a field from number to text.
So, now when we're trying to do an FT search like: [myField] = "1234" receive the error message: "Query is not understandable".
If I do: [myField] = 1234 it works but won't return any hits. Even though there's a document where myField = "1234".
The field is of type text in the design.
I've created a new view for testing, only allowing documents from one form.
Deleted the full text index (even on the file system)
updall -X
Fixup -r
Created full text index
In my test view I've got one column that shows if the field content being searched is of type text #IsText(myField) and all rows shows: 1 (so it's field content must be text)
None of the above worked so I created a new database copy locally.
Same problem.
Created an entirely new database (for testing only), form, view and full text index and that works.
Feels like the existing database design somewhere stores the old field type...
Any ideas appreciated.
Thanks!
/J
Datatypes and field names are stored in the UNK table. There is just one entry per field name, so it's critical not to use the same field name more than once in an application with different datatypes.
You need to rebuild the UNK table, as I blogged here http://www.intec.co.uk/full-text-search-musings/
Note, it must be an offline compact, as Duffbert says here http://www.duffbert.com/duffbert/blog.nsf/d6plinks/TDUF-5SMHV4. If anyone is in the database when you do the compact, it will fail and the UNK table will not be rebuilt.
Links are useful, but if you don't want to remove data from documents - for me such steps worked (and there was no need in removing fields from forms in designer):
Run from designer with manager access with such code inside
Sub Initialize
Dim s As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim i As Integer
Dim nc As NotesNoteCollection
Dim noteid As String
Dim nextnoteid As string
Dim itemArr As Variant
Dim NeedSave As Boolean
Const ITEM_NAME = "itemName1|itemName2"
itemArr = Split( ITEM_NAME, "|" )
'погромист-кун не должен забывать про наличие итемов в формах...
Set db = s.Currentdatabase
Set nc = db.CreateNoteCollection(False)
nc.SelectForms = true
Call nc.BuildCollection
noteid = nc.Getfirstnoteid()
For i = 1 To nc.Count
Set doc = db.Getdocumentbyid( noteid )
noteid = nc.Getnextnoteid( noteid )
NeedSave = false
ForAll IA In itemArr
If doc.Hasitem( IA ) Then
Call doc.Removeitem( IA )
NeedSave = true
End If
End ForAll
If NeedSave Then
Call doc.Save( True, False )
End If
Print CStr( i ) & "\" & CStr( nc.Count )
Next
End Sub
Remove database index
Run from administrator command lo compact database.nsf -c , like mentioned in links above
Create index

SPQuery sorting issue

I have this SPListItem.Folder in sharepoint that contains a property named "Asset ID".
I have this data in my list
Asset ID | Name | Asset Type
1 | GamesFolder | Games
2 | AppsFolder | softwares
3 | MusicFolder | music
In my code I did this
SPList objList = web.Lists["MyList"];
SPQuery query = new SPQuery();
query.Query = "<OrderBy><FieldRef Name='Asset ID' Ascending='FALSE'/></OrderBy>";
query.ViewAttributes = "Scope=\"Recursive\"";
query.RowLimit = 1;
SPListItemCollection items = objList.GetItems(query);
return objList.Items[0].Folder.Properties["Asset ID"].ToString();
I use .Folder because every entry in the list is a DocumentSet.
The returned value is always "1". I don't know what's wrong why my sorting
doesn't work at all.
Please help me resolve this issue. Thanks.
Hi Carls I think there is issue for field name. U include space in field name
If you want to avoid having to seek out what the internal name of a particular field is, when you first name your column, do not include any spaces or special characters. Once the field (column) has been created, go back and rename the field to include the spaces or special characters as desired. SharePoint will still retain the original field name without spaces and you can use that directly in your query without issue.
or use its internalName:
query.Query = "<OrderBy><FieldRef Name='Asset_x0020_ID' Ascending='FALSE'/></OrderBy>";
A little late but if you are having issues, you may be able to use all or a part of the following gist:
https://gist.github.com/trgraglia/4672176
And as the accepted answer states, the field name is the issue. You need to use the static name of the field. The static name will always stay the same. Even if the column is renamed. So you should get the column from the column collection by display name and then get the static name from the properties.

Resources