When importing content into a node reference field that is shared the preview import throws the following error:

Fieldname: found no valid post with that title.

I've tried with using either the node title as the reference (the array shows the correct node id) and with using the node id and the error is the same. Here are the relevant parts of of the array that is shown:

    [cck:field_drupal:value] => 
    [cck:field_company:nid] => Array
        (
            [0] => 370
        )

...

    [field_drupal] => Array
        (
        )

    [field_company] => Array
        (
            [0] => Array
                (
                    [nid] => Array
                        (
                            [nid] => 370
                        )

                )

        )

The seems related or similar to comment #7 on #236722: Not able to import to CCK "node reference" fields
http://drupal.org/node/236722#comment-1053304

I haven't dug into it deeper yet.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ChrisBryant’s picture

Upon further debugging it's not a problem with the shared node reference field. It's a problem with having node reference set to autocomplete. When changing the field to a select list the import works perfectly. It seems that if autocomplete fields are being used it shouldn't automatically convert to the nid before the import.

molly_n’s picture

Title: Error on shared node reference field: found no valid post with that title. » Error on autocomplete node reference field: found no valid post with that title.

Just changing the title of the issue...

erikwebb’s picture

Thankfully I found this post. I've noticed the same issue.

okday’s picture

I have the same issue.

subscribing

danieldd’s picture

I also have the same issue using the autocomplete box for node reference.

When I enter a correct node title name I get the error message: "found no valid post with that title" even if the title is correct. However, the error message shows that the correct nid has in fact been looked up.

When I enter the node number (eg 66786) I get the same message "found no valid post with that title." although the code shows that the nid has been correctly identified.

[field_schoolnodereference] => Array
        (
            [0] => Array

                (
                    [nid] => Array
                        (
                            [nid] => 66783
                        )

                )

        )

    [op] => Preview
)

If I enter "nid:66783" I get the message: "Input error: nid:66783 is not allowed for school (not a node reference).school field is required." [school is the name of my node ref field]

I haven't been able to try the select box workaround for this issue. The table I am referencing has 70,000 nodes and to use select box for node reference in CCK seems to crash drupal - even before I move on to node import (if anyone has a solution to this separate issue please let me know!).

In addition, my title field is not unique so will not work to reference title in this field. What I need is a way of importing a node reference to the nid (or to one of the unique CCK fields in my table if that is possible).

Does anyone have a solution? It feels like this functionality is very nearly working and it shouldn't take much to get it to work.

Aside from this node reference issue (and date) my experience is that node import works fantastically well. However, node reference is critically important.

gavranha’s picture

same for me. Works with SELECT LIST; does NOT work with AUTOCOMPLETE. (Thanks Chris. I was lost when I found your comment.)

David Lesieur’s picture

Aren Cambre’s picture

subscribe

Bodo Maass’s picture

FileSize
480 bytes

I have found the cause of this problem and can offer a partial solution.

The cause is that the validation function nodereference_autocomplete_validate in nodereference.module expects data in a different format than what is supplied by nodereference.inc of node_import. This function expects data in one of three forms:
1. "node title"
2. "node title [nid:node id]"
3. "[nid:node id]"

I was able to make it work for importing noderefs by node id. I have not tested it with importing noderefs by title, although that might work also. In the file node_import/supported/cck/nodereference.inc, the line $values[$fieldname][$i]['nid'] = array('nid' => $values[$fieldname][$i]['nid']); needs to be changed into $values[$fieldname][$i]['nid'] = array('nid' => '[nid:' . $value['nid'] . ']');

Bodo Maass’s picture

Status: Active » Needs review
Bodo Maass’s picture

Version: 6.x-1.0-rc4 » 6.x-1.x-dev
HunterElliott’s picture

in re #9. I just tried importing via the option2 method, "node title [nid:node id]" and got the errors people mentioned above. Even changing the autocomplete to a select list, at least for me, and using the standard "node title" value for the import only gave me valid imports 9% to 10% of the time.

Bodo Maass’s picture

@HunterElliott:

The options listed are the internal format that the validation function expects, NOT what you need in your csv file to be imported.

To use the patch from #9, you need to apply the patch, and then use node titles or node ids in your csv.

Cyberwolf’s picture

Subscribing

scotthoff’s picture

I get the following error message when i try to do my node import.

I am trying to import into a field that has 2 node references. The node references are passed. It says that they cannot find posts with that title. However, I the posts do have that title. I am not sure where to start.

Record 1:

Original Word:found no valid post with that title.
Translated Word: found no valid post with that title.

values = Array
(
    [created] => 
    [node_import_build_mode] => 1
    [title] => accent
    [type] => translation
    [cck:field_orginal:nid] => Array
        (
            [0] => 4078
        )

    [cck:field_translation:nid] => Array
        (
            [0] => 3916
        )

    [log] => Imported with node_import.
    [revision] => 
    [uid] => 1
    [sticky] => 0
    [promote] => 1
    [status] => 1
    [path] => 
    [comment] => 2
    [field_orginal] => Array
        (
            [0] => Array
                (
                    [nid] => Array
                        (
                            [nid] => 4078
                        )

                )

        )

    [field_translation] => Array
        (
            [0] => Array
                (
                    [nid] => Array
                        (
                            [nid] => 3916
                        )

                )

        )

    [name] => scotthoff
    [taxonomy] => Array
        (
        )

    [op] => Preview
)
CreatixEA’s picture

Hi,

I had the same issue. If I change the field's widget to "list of selection" that works correctly (if set as "autocomplete text input" that failes ...)

scotthoff’s picture

It is correct This does fix it. However, now if I dont' do it via import the process is near unusable.

Anonymous’s picture

Subscribe

scotthoff’s picture

It seems like the only option is to move back and forth between the settings depending on the task?

drupalerocant’s picture

Hello, I had the ame problem and was fixed with changing to select list.
thank you very much

dandaman’s picture

Here's a patch that might help this issue: it should now work with both Select lists and the Autocomplete version.

Vacilando’s picture

Same problem... getting "Input error: John Doe is not allowed for Pupil (not a node reference)" even though there is an entry in the import file for "John Doe".

Unfortunately, dandaman's patch has not solved the problem - in my case at least.

dandaman’s picture

Sorry, mine helps if you're putting NIDs in the nodereference field for the import.... vacilando, obviously you're putting in the title in the field... is it set up as a select, checkbox, or autocomplete?

Vacilando’s picture

dandaman, I do use it for titles, yes. I had set it up as autocomplete, then changed to select, with the same negative result.

jcodina’s picture

Subscribe

jcodina’s picture

if there various node reference fields in a content type there is no way to import content. If there are only one is possible

dandaman’s picture

frierab, I got it to work with a bunch of NIDs separated by pipes for multiple references. I most likely was using the patch that I provided above, but I did get it to work somehow.

Exploratus’s picture

subscribe

dustobub’s picture

Has anyone found a solution to using Node Titles + Autocomplete Widget? I need to use Autocomplete as I am using the Node Relationships plugin for the additional search/create/edit functionality.

@frierab, have you found a solution to the multiple node references per content type issue?

Thanks,
Dustin

verres’s picture

i'm having the same difficulty - import hangs because node-import doesn't like the value in the node-reference field. I've tried switching the node-reference field widget to select list (from autocomplete) and I've tried formatting the import file to be, (1) the title value, (2) the node id value and (3) '[nid:node id]' ... in no cases does the module recognize the value of this field....

travVT’s picture

Hey Everyone,

I'm having the same issue as well, but I was able to work around this by doing the following:

1.) Switch the type of the CCK field to "Select List"
2.) Use Node Import to load data
3.) Switch the type of the CCK field back to "Auto Complete"

I haven't discovered any issues with this method yet, but I'll keep you posted!

Thanks,

Trav

DarrellDuane’s picture

#22 worked for me when I had node titles in my CSV file. This was patched against the -dev version as of today.

HansKuiters’s picture

#22 worked for me with nid's in my csv (just a number, no 'nid:' prefix). Thanks.

alanpeart’s picture

Lifesaver! Thank you....#22 was the charm.

Jorrit’s picture

Status: Needs review » Reviewed & tested by the community

#22 worked for me too.

Josh Benner’s picture

#22 confirmed further. Seems ready for commit?

Mac_Weber’s picture

Try changing the nid value to "[nid:xxxx]"
It may be related to http://drupal.org/node/1353662

I posted a tutorial of how I solved it for the Services 3 module with NO lines of code:
http://drupal.org/node/1354202

deranga’s picture

Thanks Bodo, this helped me to get it working as below

For anyone else I used the following with an auto-complete node reference field in Drupal 6:

$node_tmp = array('type' => "YOUR_CONTENT_TYPE");
$form_state['values']['YOUR_NODE_REFERENCE_FIELD'][0]['nid'] = array("nid"=>"[nid:".$node->nid."]");
drupal_execute('YOUR_CONTENT_TYPE_node_form', $form_state, (object)$node_tmp);
hovel’s picture

You can find my solution here: Cannot import nodereference autocomplete nor nodereference buttons fields
It solves problems I had importing nodereference autocompletion and nodereference buttons fields.