Wednesday 9 October 2019

D8 custom entity reference field not working.

Drupal 8 custom entity reference field not working. 


On our site we've added a field that links to an Entity with the Entity Reference functionality.

When using is I just get a spinning circle and it never resolves.


The issue I had was that in the Schema of my custom Entity I had the 'label' set up incorrectly.


The file to change was in

my_custom_entity
     -- config
           -- schema
                   -- company_entity_type.schema.yml


company.company_entity_type.*:  type:  my_custom_entity  label: 'Type config'  mapping:    id:      type: string      label: 'ID'    label:      type: label      label: 'Label'    uuid:      type: string
Change this too .
company.company_entity_type.*:
type: my_custom_entity label: 'Type config' mapping: id: type: string label: 'ID' label: type: title label: 'Title' uuid: type: string

Tuesday 24 September 2019

Drupal 8 - changes were detected in the entity type and field definitions. The % field needs to be updated.

While installing and Uninstalling Modules of Drupal 8 - using the Migrate tool I came across this issue.


Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.

AND THEN YOU GET A LIST

Something like




I have found two solutions for this , depending on whether this is a mismatched entity or field definition.   So I will list both .  Make sure you have a full backup of your site before you try these.


For Entity mismatches - what we need to do is cleanly remove our Modules, but cannot use the normal way as it gives us an error. 
Here's a lazy one liner.

drush eval "\$module_data = \Drupal::config('core.extension')->get('module'); unset(\$module_data[‘company’]); \Drupal::configFactory()->getEditable('core.extension')->set('module', \$module_data)->save()";

Here the module is called 'company' , you would swap that out for what you wish.php ../vendor/drupal/console/bin/drupal cache:rebuild
And when you've checked the site and are happy we should Export our new configuration 

php ../vendor/drush/drush/drush cex


FIX the FIELD DEFINITION 

That fixes all but the 'Name' field needs to be updated bug. 
For this I had to install this module 
https://www.drupal.org/project/devel_entity_updates
First of all I had to remove the Entity updates module .  You remove this by hand in the composer.json file .  And then run composer again
run composer

Now in the container Enable the module .  

drush pm:enable devel_entity_updates
And run the 'entup' command. 

drush entup


Here are some additional notes that I made while looking for this solution; that may help others find this article. 
I attempted to use updateFieldStorageDefinition(FieldStorageDefinitionInterface $storage_definition);


What is the storage_definition for our field

How to find what the storage definition is for a field in Drupal 8. - that leads us here https://www.drupal.org/docs/8/api/entity-api/defining-and-using-content-entity-field-definitions

Drupal 8 get The field storage definition

Drupal 8 Errors found Entity / field definitions the % field needs to be updated hook_update_N getFieldStorageDefinition
Fix Drupal 8 The % field needs to be updated. hook_update_N issue

And then through that search I found that https://www.drupal.org/project/devel_entity_updates 


Saturday 11 May 2019

Help finding a Part for the Toyota Alphard

This is a really simple tip but I think it worth noting as I found it difficult trying to find specific parts for my Toyota Alphard. 

This tip isn't just for the Toyota Alphard but it will be of help to owners of ANY other vehicle that can't find there parts on Ebay or a Car spares websites.

All you need to do is remember the work 'breaking'  !!  This may seem obvious to many but didn't occur to me ( a non mechanical person )

So go to Ebay and type in

'Toyota Alphard Breaking'  - or replace the car make with your own, and hopefully you should see some options of sellers who are scrapping a vehicle and selling off all the parts.

https://www.ebay.co.uk/sch/i.html?_trksid=toyota+alphard+breaking.TRS0&_nkw=toyota+alphard+breaking

Thursday 2 May 2019

Toyota Alphard 2003- How to remove the tail light / indicator lights.



I couldn't find any videos or help on this for my exact module , so I thought I'd note it here.  With a picture.

Other similar Toyota models have a clip you push out.  And if you were to follow that as an example there is possibility that you'd break the housing

With my Toyota Alphard you remove the bolt and then push the housing towards the back of the vehicle. 

If you take a look at these images that should help .



Wednesday 24 April 2019

Deleting Multiple Tables from your Database using Terminal

Here's a really simple way fo getting all your Database table and deleting them, without having to write and scripts.

I'm using Terminal on a Mac here and I've SSH'd into the server. And then accessed my database so I can type in my queries directly .

What you want to do here is write a 'DROP TABLE' command that will include all of your tables.
Like

DROP TABLE IF EXISTS A,B,C;

To get a full list of all of your tables you can use.

SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE';

Using this list I've copy and pasted this into a text editor. You'll need one the has a decent copy and paste facility.

You'll get something like

| table_one |
| table_two |


Replace
"|"
for
","

And then Replace
" ,"
for
""

AND then replace the first "," for "DROP TABLE IF EXISTS "

And the last "," for ';"

You can now copy and paste this into terminal.

Friday 5 April 2019

Google Sheets Scripts - A basic helloworld example

I've written this note after an issue has been noted due to one of my scripts not working in Google Sheets.   And this is a pretty helpful way of troubleshooting any issues.   To work backwards from this. 

Troubleshooting Google Scripts
If you've got an issue you'll see "#NAME?" 

Hover over this and you'll see a report of the issue.




One way to run a test is to build up you're function from scratch .  

Let's just run a 'hello world ' example.
So let's use a function call 'SwapStringTest' .

we can call this using a SUM in the cell A1


=SwapStringTest("Hello World")
In our Scripts ( Tools > Scripts )

We'd use

function SwapStringTest(string){
 
 return  string
 }
This will simple print out 'Hello World' into our first cell.



From here I could pass every section of the function I had and found that the  STARTDATE was producing a NaN value.

to fix is I used
$start = end_date_obj.setDate(0);
 
// for the month prior to
 
$end = end_date_obj.setDate(1);

Tuesday 2 April 2019

How to save for that family holiday

Actually this is more a ‘How I’m going to save’ for my holiday. Everyone’s different and theres a wealth of information online. For example; you may buy 2 coffees a day at £5 . That’d be a saving of £1300 a year, you’re almost done !

I’ve priced it up and we should be able to go on our next snowboarding holiday for around £2,000, a blog on that will follow shortly.

Here’s some things that I’m going to be following. Pretty much all this can be found at moneysavingexpert.com, so be sure to check there for more inspiration for your own savings that can be made.

Moving Bank Accounts . I’ve done this every year for the last 2 years. It’s work £150 ish. Nationwide is a good one to have . I recommended a couple of friends last year and received £200

If you want a Nationwide account then why not email me and I’ll send you a link :)

Compare all your bills against comparison sites. You’ll be able to bring one down by £10 a month for sure. That’s £120 off for the year.

Nectar ( Bonus ) Card. As I work next to Sainsburys and use BP.me I get to collect about £120 a year.

Make you own Cider / Champagne - this is a decent saving for us , I’m putting down for £200 a year.

Micro managing spending. Using Google sheets keep a close eye on what coming in and going out . Monitor the 1st month and then try and stock check and tweak to save £10 a month. I’m taking £110 off the total for this one.

Re ignite my blog and get Adsense vouchers. The aim is to get a £60 voucher for the next holiday. I did want to also reignite my YouTube channel , but you now have to fulfil a fairly high criteria to able to add advertisements.

Sale stuff on Ebay . I’ve taken off all the above calculated amounts from my £2k total and it’s left me with £21.50 a week to raise through Ebay. So every weekend I’ll try and add £20+ off stuff on there. This I fear is going to be too difficult a target to reach, as I'm a few weeks in and have hardly made a penny. So Nuumber 9 here may well come into play.

Promote other offers online a receive bonuses. Like AirBnB you get £15 if others complete a stay - plus they get £25 off . So if you’re thinking of using AirBnb then let me know ;)

Overtime - if all else fails I’ll just have to do a little bit more work ! :(

TaskProfit
Moving Bank Account£150
Compare Bills£120
Nectar Card£120
Make own Cider / Champagne £200
Micro manage spending£110
Re ignite Blog£60
Sell stuff on eBay200
Promote offers for Bonuses.£200
Overtime£840

I'll report back with how I get on.

Wednesday 27 March 2019

Mysql - using REVERSE LEFT GROUP and GROUP CONCAT to find string that match except for proceeding characters

This was the problem I was trying to solve.
MySql search to find IDs that match but some the Proceed with a Zero

This is a pretty niche little issue eh!


In one of our Software applications we have users with Payroll IDs, but some had been imported with Zero's at the beginning and some without.   Probably due to some excel settings !

What I wanted to do was write a query for this to find these issues.


To solve this I used this logic

1.    I would REVERSE the Payroll Id's
2.   That way I could match the first 6 digits on the LEFT before the we'd get to a zero !
3.   GROUP those that matched
4.  COUNT them and put the highest amounts to the top
5.  Show all of the Payroll Ids so that I could scan the list easily to see which ones could be an issue.



Here's my query.



SELECT count(*), GROUP_CONCAT(identifier) Identifiers FROM eck_payroll as p
WHERE p.identifier != 0  AND p.`state` = 1
GROUP BY LEFT(REVERSE(p.identifier),6)
ORDER BY count(*) DESC;

Monday 25 March 2019

How to batch multiple Queries together in Sequel Pro

I’d searched for a handful of things to solve this issue, and in the end it was quite simple.
So I thought I’d note it here.
Here are some of the terms I searched
  • 
‘Mac automate multiple sql commands’
  • 
’sequel pro run multiple queries’
  • 
‘sequel pro query window mulitple commands on run’


Here’s what the problem I was trying to solve was

I had a sql statement that was crashing, however I could run in with a LIMIT of 1000


> Click in the Query window.
> Add your query and then copy and paste the amount of rows you need. 

> Click on 'Ctrl+R'

And that’s it. 


Tuesday 12 March 2019

Using OnEdit to add Date to Previous Cell in Google Sheets

Here's a nifty bit of code that will add a Date to the cell of your row when you enter data in the 3rd cell.


function onEdit(e) {
 
    var ss = e.source.getActiveSheet();
    if (ss.getName() !== 'sheet1' || e.range.columnStart !== 2return;
    e.range.offset(0, -1)
        .setValue(e.value ? new Date() : null);
}


Or if you want to have it on a couple of sheets you could use


function onEdit(e) {
 
    var ss = e.source.getActiveSheet();
  if (ss.getName() == 'sheet1' && e.range.columnStart == 2) {
    e.range.offset(0, -1)
        .setValue(e.value ? new Date() : null);
  }
  else if (ss.getName() == 'sheet3' && e.range.columnStart == 2){
    e.range.offset(0, -1)
        .setValue(e.value ? new Date() : null);
  }
  else if (ss.getName() == 'sheet5' && e.range.columnStart == 2){
    e.range.offset(0, -1)
        .setValue(e.value ? new Date() : null);
  }
  else {
   return; 
  }
  
}


Saturday 9 March 2019

What different voice operations are there on my phone ?

What different voice operations are there on my phone ?


I have a Samsung S9 , and I thought it may be useful to others to list the ways in which I using voice commands.
Talking to your mobile to operate it and to connect to the internet is on the rise.  It’s not only often much quicker than manually operating but it also means you can use your phone hands free.  Handy if you’re Driving.

1. Google shopping list
2. Google Routines
3. Reminders
4. Sending and receiving messages
5. Sat Nav Features
6. Asking assistant to convert something for me.
7. Chatting with Google Translate
8. Dictate something to text.  Using Voice Recorder
9.  Using Pocket to Readme a Webpage
10. Help making calls hands free calls


Google Shopping List

Just add stuff to it whenever it comes into your head 

“ok google, add XXXX to my shopping list”
"show me shopping list "
You can also have multiple contributors, so everyone in the family can add to the same list. 

> To do this just click on the person icon in the top right. 

Google Routines

This is basically a wrapper for all the things you have access to in Google Assistant.  So you can string a whole heap of stuff together.
Here’s an example for you.  On a midweek night I pick up the kids and their friends from a sports activity.  I’ve programmed run this routine when I say “Ok google I’m ready to pick up”

Google then -
1. Tells me the time
2. SMS messages the parents
3. Checks my route home and tells me how long it’ll take.
4. Read my Reminder
5. Tell me a riddle ( something to amuse the kids when the get in )
6. SMS messages my wife to say I’m on the way.

There are preset Routines and you can add as many others as you'd like
1. Open Google APP
2. Go to ‘Settings’
3. Click on Google Assistant
4. Click ‘assistant’ tab
5. Click on Routines



Reminders

Using reminders at using Google assistant as a second memory is a great for someone like me who has a terrible memory.   You can set reminders on a timer, for example 
“Remind me tomorrow morning that I need to get petrol”

You can also set a reminder on location 

“remind me in Newquay Town that I need to get Petrol “

Not only that but you can just set a reminder like 

“Remember that Mike Smiths wife is called Ann”  

and then to retrieve that you’d say 

“Remind me what was Mike Smiths wife called”




Sending and receiving messages


I’ve been sending, receiving and getting read for me ; from Gmail, SMS and WhatsApp.
"Send an Email to Mum"
"Read my last email ( from XXXX ) "
"Send a SMS message to XXXX"
"Send a Whatsapp message"
"Send a Voice message"


Sat Nav Features

“Navigate to WHEREEVER”
“Get driving directions to WHEREEVER”

Tip; if you set up your personal locations in Google Maps then you can say “home”, “work”, “Mums”, ‘the Gym” etc.  This one will impress your passengers !


Asking assistant to convert something for me.

Convert Lengths, Area, Temperature, Volume, Mass & Data.  Also ( this was a revelation to me ) calculate currencies, it even does the more random ones like Czech Koruna .

"what is 15% of 135"
"how many centimetres in 2 foot"
"How much in British Pounds in 10 thousand Czech Koruna"

Google Translate


Using Google Translate is a great way to learn some basics of a language.

“What the spanish word for XXXX”
“How do you say XXXXXX  in spanish”


Podcasts and Text to Speach

Find out what Podcast that you think will be good for you to listen to.  And then use.

“Listen to XXXXX Poscast”
“Play the latest episode of XXXXXX”
“Recommend a podcast”

If you’re looking for a Text to Speech APP then I use Pocket which is awesome.  Presave your webpages that you want it to read and then when you start your journey click on the headphones and get it read back to you.




Initiate Phone Call

This one should probably be higher of the list but you can also use your phone as a phone.
Who knew eh!

Voice control helps you initiate the calls

“call a mum at home on speakerphone”




If you’ve got any call features you use then why not let me know, I’m also looking for more ways to increase my usage of Mobile phone voice assistant options.

Most of the advice I’ve wirtten about above can from Googles documentation.


https://assistant.google.com/explore