TYPO3: How to check if a record is new or just a copy - copy

I implemented two hooks (processDatamap_afterDatabaseOperations and processDatamap_postProcessFieldArray) to manipulate any record after saving.
My Question is:
Every time I copy or create a record I enter the hooks and get a parameter "status" which is always "new" no matter if the record is actually new or just a copy of an existing record.
It seems like TYPO3 handles copies as new records.
How can I check if a record is actually a copy or a new record?
I am currently working with TYPO3 Version 8.7.9.

You can use the t3_origuid.
It should be added to your extbase domain model.
See here.
After handling the "copy" command the id of the original record will be copied into this field.
So in the hooks:
processDatamap_preProcessFieldArray or processDatamap_postProcessFieldArray you can access to it.
Like:
if(isset($fieldArray['t3_origuid']) {
<your_code>
}

Related

Flutter hive change field

I am creating a app in flutter and I am using Hive.
I have created some models and registered typeadapters.
Eg:
Normally its : create model with annotations -> run build runner -> register type adapter -> use box
So my question is when I have to do some changes again in model and I have to run build runner again so that fields get updated in generated adapter.
I have to remove all appdata or uninstall app so that I can store data into new structure.
The problem is every time I change a field or add a field due to previosly stored data in box ,it gives error, I have to delete the app or remove its data.
How can I make changes to model without deleting previous data.
As from the official documentation of the Hive package, you need just to follow those steps in order to delete, add, and update a field in your adapter:
Don't change the field numbers for any existing fields.If you add new fields, any objects written by the "old" adapter can still be read by the new adapter. These fields are just ignored. Similarly, objects written by your new code can be read by your old code: the new field is ignored when parsing.Fields can be renamed and even changed from public to private or vice versa as long as the field number stays the same.Fields can be removed, as long as the field number is not used again in your updated class.Changing the type of a field is not supported. You should create a new one instead.You have to provide defaultValue for new non-nullable fields after enabling null safety.

Changing field length through PHP Script

I Want to change field length through a PHP script and Sugar beans in both database and Sugar CRM studio
You're question is very vage and doesn't show us what you've already tried, but I'll give it a go regardless:
Custom fields
Studio saves custom fields in DynamicFields beans, which are saved in database in the fields_meta_data table. The field's id is module name + field name, e.g. Accountstests_c for field test_c.
One way to change it is by updating the len column in the table and then run a Quick Repair & Rebuild (see notes below).
Alternatively you could adjust the field using the DynamicFields beans or using the ModuleBuilder's PHP controller similar to how Studio does it (I'll try to add an examples later).
Stock fields
You can adjust a field's length using Vardefs-Extensions.
E.g. if you want to change length (vardef attribute len) of the varchar-field name in module Accounts to 100:
./custom/Extension/modules/Accounts/Ext/Vardefs/sugarfield_name.php:
<?php
$dictionary['Account']['fields']['name']['len'] = 100;
Notes
Run a Quick Repair & Rebuild and your change will be applied in Sugar and Studio. Then scroll down and run the suggested DB changes.
If you want to do this without user interaction find or write a sugarcrm repair script.
When creating new Vardef extensions make sure to use the BeanName for the dictionary array index, so Account for Accounts or aCase for Cases. If unsure what to use, just see how existing vardefs files of the module in question do it.
For available vardefs attribute names and more insight into vardefs see here or look at the vardefs.php files in the modules/ subfolders.

Change the name of an item in a custom field using API

I am looking for a way to change the names of the items in a custom field I created in studio, without changing their display labels.
I used the field editor (still in studio) to change the associations between names and labels, but despite my modifications, I am still getting the former names (those that were defined before my modifications) when I'm using the API.
How can I make the new names be effective?
Thank you for your help.
When you change the keys in a dropdown list (you called them 'names'), it will change the language file in SugarCRM, but will not change the existing values in your database. So a query to existing records that used the old keys will still return those old key values.
You will need to perform UPDATE queries in your database similar to:
UPDATE contacts_cstm SET mydropdownvalue_c='NewValue' where mydropdownvalue_c = 'OldValue';

Filemaker Pro 14 History tables

With a few solutions Ive worked with I've created temp table's or history tables. Normally I script it to take a handful of fields needed from a main table and copy it over to the other table by
Setting a variable then setting field to the variable for each field in the new table / new record.
I have a situation now, where Im building a history table that needs to copy the current record as is. A snapshot where all fields from that instance of the record are copied to the history table.
Rather then setting a variable then set field to the variable, Id like to get some input on a quicker way to get this done where I can do this on a record level and not type out field by field to get it done. Also if fields are added to both tables then I have to make sure my script gets updated.
Ill keep hunting around.. appreciate any help.
-Rich
Do you have a sample of copying a record from 1 table to another
including all fields and setting some fields?
As I suggested in comments, use the Import Records[] script step, and select the same file as the source. If you choose Arrange by: [ matching names ] in the Import Field Mapping dialog, it will automatically map all source fields to their similarly named counterparts.
Note that you must establish a found set in the source table before importing.
For "setting some fields", you can define auto-enter options and activate them during the import, or run Replace Field Contents[] immediately after the import.

Is it possible to store hidden metadata information that is tied to a specific Table or Cell within a Word document?

I am trying to store metadata (basically a unique id) along with each cell of a table in a Word document. Currently, for the add-in I'm developing, I am querying the database, and building a table inside the Word document using the data that is retrieved.
I want to be able to save any of the user's edits to the document, and persist it back to the database. My initial thought was to store a unique id along with each cell in the table so that I would be able to tell which records to update. I would also like to store some sort of "isChanged" flag within each cell so that I could tell which cells were changed. I found that I could add the needed information into the "ID" property of the cell - however, that information was not retained if the user saved the document, closed it, and re-opened it. I then tried storing the data by adding a data to the "Fields" collection - but that did not work and threw a runtime error. Here is the code that I tried:
object t1 = Word.WdFieldType.wdFieldEmpty;
object val = "myValue: " + counter;
object preserveFormatting = true;
tbl.Cell(i, j).Range.Fields.Add(tbl.Cell(i, j).Range, ref t1, ref val, ref preserveFormatting);
This compiles fine, but throws this runtime error "This command is not available".
So, is this possible at all? Or am I headed in the wrong direction?
Thanks in advance.
Wound up using "ContentControls" to store the information I needed. I used the "Title" field to store the unique id, and the "tag" field to track whether the field had been changed or not. See this link for more info: http://blogs.technet.com/gray_knowlton/archive/2010/01/15/associating-data-with-content-controls.aspx
Since a "Word 2007 Document" is XML, you can add a namespace to the document then adore the elements with attributes from your namespace. Word should ignore your namespace when loading and saving. Moreover, you can add new elments to store any information (metadata) needed.
With that said, I have not used this technique with Word, but I have done it successfully using Excel 2003.
First thing to try, is create a bare "Word 2007 Document". In your case, add a simple two by two table. Open it with a text or XML editor and add your namespace, and adore an attribute and add an element. Open with Word make a change then save it. Open with editor and make sure your namespace attribute and element have not been changed.