So now I need to write the function. The hard thing is that I will need to make a research in my CSV for every line of the opportunities’s name to find the ID, to update the correct line of my opportunities module.
Tried to look at /SuiteCRM/modules/Import/ to copy some code, but there is so much file and code that I don’t really know where to start ahah.
This is a “basic” question, I think I’m not the only one who will have this need. I’ll update here how I’ve done it for everyone who’s interested.
I should warn you that the chat room on Gitter is really not for technical support, I am afraid. If you go there with issues in the format “please help me, I have a problem”, you’re in the wrong place. The Forums are the correct place for that.
That chat room is just meant for developers who have previously contributed to SuiteCRM on Github, and the discussions revolve around things Like PR’s, tests, documentation, and coding issues in Core product. It’s public, of course, and everybody’s welcome there, of course, but it needs to stay on topic, I am sure you understand.
About your current thread here, as a preliminary question, I wonder if you really want a Scheduled task? Maybe a custom Entrypoint would be better? I am saying this because if we need to move the CSV file into your server manually, you might as well just run the entrypoint when after you put it there. You have the additional advantage of being able to output results to screen more easily.
The sample I meant to show you is this importer here:
About the scheduled task or custom Entrypoint, I dont really care. I was thinking the sscheduled task was my only option.
In fact My needs is to import a CSV file when im not here, for example, putting a CSV file during the week, import it during the night or in the weekend to not disturb my users.
It’s hard to debug from a distance, you will have to figure it out yourself…
Is your CSV file the proper format? Check it in Notepad++
Then see if it’s picking up the $campos variable correctly (BTM, “campos” means “Fields”, I should have translated that to English). Uncomment line 266 to see it on screen.
Its every time say its in ASCII ahah… Even if I change the encoding with notepad++ and if I take another file it say its ASCII, so maybe the piece of code dont work.
And yes, the campos work, super piece of code I can access every fields, its work great. In fact everything work but due to this shitty bug it loop one more time.
But pretty sure your right, its an encoding bug, will continue my research to find a solution !
And after array_shift() I do $NombreLigne = $NombreLigne -1; to get the good number of line
I’ve got now an other question, I’ve checked on internet and in the doc. Im looking for a way to know If a bean exist in the database (to not import an already existing line.)
For now I use retrieve_by_string_fields() If its null the line doesnt exist, if not It already exist… But I dont know if the good way to do it, cant really find help on internet.
My function GetOrCreateSimpleContact does exactly that. There are several ways to check the database, the one you mention is one of them, you should be ok.