# Importing a CSV File using your own code

**URL:** <https://forums.knack.com/t/importing-a-csv-file-using-your-own-code/9231>\
**Category:** Show & Tell\
**Created:** [February 10, 2019, 10:39am UTC](https://forums.knack.com/t/importing-a-csv-file-using-your-own-code/9231 "2019-02-10T10:39:33Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeterDay82531](https://avatars.discourse-cdn.com/v4/letter/p/c57346/32.png) [@PeterDay82531](https://forums.knack.com/u/PeterDay82531)\
**Post date:** [February 10, 2019, 10:39am UTC](https://forums.knack.com/t/importing-a-csv-file-using-your-own-code/9231/1 "2019-02-10T10:39:33Z")

</div>

Its has been a while since I posted. But thought I would share a bit of code I have just developed. Its raw but works for my purpose. It will let you upload a csv file into a nominated object (Database). I hope the community finds it useful and improves on me first attempt.

&nbsp;

Peter

&nbsp;

$(document).on('knack-view-render.view\_##', function (event, view, data) {

&nbsp;

//-----------------------------------------------------------------------------------------

// This function will take the csv file that is uploaded using #load-file click

//event below

//------------------------------------------------------------------------------------------&nbsp;

&nbsp;

function processData(allText) {

&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp; var allTextLines = allText.split(/\r\n|\n/);

&nbsp;&nbsp;&nbsp; var headers = allTextLines[0].split(',');

&nbsp;&nbsp;&nbsp; var lines = [];

&nbsp;&nbsp;&nbsp; var MyData = {};

&nbsp;&nbsp;&nbsp; for (var i=1; i\<allTextLines.length; i++) {

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var data = allTextLines[i].split(',');

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (data.length == headers.length) {

&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var tarr = [];

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (var j=0; j\<headers.length; j++) {

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tarr.push(headers[j]+":"+data[j]);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lines.push(tarr);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

//Create the data for the record POST&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyData = {

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; field\_108 : data[0],//Replace with your fields in your object. Should match your csv file

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; field\_109 : data[1],

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; field\_110 : data[2],

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; field\_111 : data[3]

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }

//Create a new record for each line of the csv file&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newrecord(MyData)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }

&nbsp;&nbsp;&nbsp; }

&nbsp;&nbsp;&nbsp;&nbsp; //alert(lines); //used if just showing the output

}

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

/\*---------------------------------------------------------------------

Peter Day 27/1/2019

Function to create a new record

---------------------------------------------------------------------\*/

function newrecord(Mydata)

{

&nbsp;&nbsp; $.ajax({

&nbsp;&nbsp;&nbsp; url: '[https://api.knack.com/v1/objects/”Your](https://api.knack.com/v1/objects/%E2%80%9DYour) object ie. Object\_5”/records',

&nbsp;&nbsp;&nbsp; type: 'POST',

&nbsp;&nbsp;&nbsp; headers:

&nbsp;&nbsp;&nbsp; {

&nbsp;&nbsp; 'X-Knack-Application-Id': "API ID",

&nbsp;&nbsp; 'X-Knack-REST-API-Key': "API Key"

&nbsp;&nbsp;&nbsp; },

&nbsp;&nbsp;&nbsp; data : Mydata,

&nbsp;&nbsp;&nbsp;&nbsp; success: function(data)

&nbsp;&nbsp;&nbsp; {

&nbsp;&nbsp;&nbsp;&nbsp; alert('Successful New');

&nbsp;&nbsp;&nbsp; }

&nbsp; });

}

&nbsp;

//-------------------------------------------------------------------------------

// Load file actions when the prescribed button is clicked. This can be embedded

// in a Rich Text Field&nbsp; by pasting the following into the HTML area of the Rich Text field:

// \<input type="file" id="file"\>\<input type="button" id="load-file" value="Load"\>

// or you can simply create a .kn-button and replace an event for this button being clicked.

// Once the file is loaded it calls processData which loops through it, strips out the ‘,’ and

// loads into an array to POST using the API

//--------------------------------------------------------------------------------

&nbsp;

&nbsp; $( '#load-file' ).click( function () {

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //alert("here");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp; var MyData = {};&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp; if ( ! window.FileReader ) {

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return alert( 'FileReader API is not supported by your browser.' );

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var $i = $( '#file' ), // Put file input ID here

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; input = $i[0]; // Getting the element from jQuery

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp; if ( input.files && input.files[0] ) {

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; file = input.files[0]; // The file

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fr = new FileReader(); // FileReader instance

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fr.onload = function () {

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; processData(fr.result);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fr.readAsText( file );

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //fr.readAsDataURL( file ); // Swap with the above if a JSON file

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else {

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Handle errors here

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert( "File not selected or browser incompatible." )

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }

&nbsp;&nbsp;&nbsp;&nbsp; });

&nbsp;

});

&nbsp;

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![ZapBaum60976](https://avatars.discourse-cdn.com/v4/letter/z/8dc957/32.png) [@ZapBaum60976](https://forums.knack.com/u/ZapBaum60976)\
**Post date:** [September 23, 2020, 2:11am UTC](https://forums.knack.com/t/importing-a-csv-file-using-your-own-code/9231/2 "2020-09-23T02:11:26Z")

</div>

Does anyone know how to change the code so that the scene reloads once all the records are imported?

Or, how should the code be changed to show an Alert once ALL the records are imported (instead of the alert that now shows every time a new record is added)?

Thanks!

---

<div class="post-metadata">

**Author:** ![Vinnie](https://avatars.discourse-cdn.com/v4/letter/v/71e660/32.png) [@Vinnie](https://forums.knack.com/u/Vinnie)\
**Post date:** [January 31, 2020, 2:18pm UTC](https://forums.knack.com/t/importing-a-csv-file-using-your-own-code/9231/3 "2020-01-31T14:18:45Z")

</div>

Thanks Justin,

Appreciate the information.&nbsp; I'll look into this and see if I can move it forward.&nbsp; Any findings will post up ;-)

&nbsp;

Vin

---

<div class="post-metadata">

**Author:** ![Justin11773](https://avatars.discourse-cdn.com/v4/letter/j/5fc32e/32.png) [@Justin11773](https://forums.knack.com/u/Justin11773)\
**Post date:** [January 31, 2020, 1:51pm UTC](https://forums.knack.com/t/importing-a-csv-file-using-your-own-code/9231/4 "2020-01-31T13:51:52Z")

</div>

For Connections you need to post the guid (knack calls record.id) rather than the identifier. If coming from a csv you will not have that value. You would need to add a function to the script that searches for each identifier and returns the corresponding guid, then use that value in place of whatever value was in that place on the csv. Not easy to write but it would be an awesome upgrade to this script. you could also parse a connection value from the page you're on it if happens to be there already. ie you are on a customer page and want to upload transactions to that customer and every connection field that you need to populate is represented on the rendered page you are currently on. that would look something like this:

//Use the inspector to identify the selector of the connection field displayed on the page.

var myConnectionField = $('#getSelector).text();&nbsp; //replace getSelector with your selector.

//guid is stored in the span so use .text()

console.log('my connection is: ', myConnectionField); //test that you are getting the record id value from the span

//should look like this '54325435454rerefd5454efdr54' ie a random string of letters and numbers.

---

<div class="post-metadata">

**Author:** ![Vinnie](https://avatars.discourse-cdn.com/v4/letter/v/71e660/32.png) [@Vinnie](https://forums.knack.com/u/Vinnie)\
**Post date:** [January 31, 2020, 11:40am UTC](https://forums.knack.com/t/importing-a-csv-file-using-your-own-code/9231/5 "2020-01-31T11:40:38Z")

</div>

managed to get this working cool! However I'm having dificaulty with relationhip fields being populated

---

<div class="post-metadata">

**Author:** ![Vinnie](https://avatars.discourse-cdn.com/v4/letter/v/71e660/32.png) [@Vinnie](https://forums.knack.com/u/Vinnie)\
**Post date:** [January 31, 2020, 8:08am UTC](https://forums.knack.com/t/importing-a-csv-file-using-your-own-code/9231/6 "2020-01-31T08:08:01Z")

</div>

I know this is an old post.&nbsp; But I'm new to knack and not sure at present how customisation works.&nbsp; Would it be possible for someone to talk me through the process above including adding buttons etc..&nbsp; I unaderstand the concept but its just not working for me this side.&nbsp;

Thanks in advance

Vin

---

<div class="post-metadata">

**Author:** ![Justin11773](https://avatars.discourse-cdn.com/v4/letter/j/5fc32e/32.png) [@Justin11773](https://forums.knack.com/u/Justin11773)\
**Post date:** [February 27, 2019, 4:00pm UTC](https://forums.knack.com/t/importing-a-csv-file-using-your-own-code/9231/7 "2019-02-27T16:00:13Z")

</div>

Wow! I have some code to do this same thing (which I found online years ago.) It was hundreds and hundreds of lines of code.

This is so much more readable and manageable. Thank you!

---

<div class="post-metadata">

**Author:** ![StephenChapman](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/stephenchapman/32/1759_2.png) [@StephenChapman](https://forums.knack.com/u/StephenChapman)\
**Post date:** [February 25, 2019, 3:03am UTC](https://forums.knack.com/t/importing-a-csv-file-using-your-own-code/9231/8 "2019-02-25T03:03:20Z")

</div>

This is some excellent bit of code! Thanks Peter.  
Is there an easy way that you'd use the ID of the active page to create connected records?  
  
EDIT: I managed to figure it out by adding a variable outside the processData function that gets the record ID from the rendered Details view, and a line to the MyData initialisation, _field\_5_ being the connected record field, and _[recordID]_ being the variable of the connected ID.  
Haven't yet tried to get more than one connection field, nor a connection field with a many relationship.

---

<div class="post-metadata">

**Author:** ![ZapBaum60976](https://avatars.discourse-cdn.com/v4/letter/z/8dc957/32.png) [@ZapBaum60976](https://forums.knack.com/u/ZapBaum60976)\
**Post date:** [February 11, 2019, 4:53pm UTC](https://forums.knack.com/t/importing-a-csv-file-using-your-own-code/9231/9 "2019-02-11T16:53:43Z")

</div>

Thank you for this Peter!

&nbsp;

The records in the CSV file are added to my object perfectly. I also need another field in the same object to be automatically updated with the specific logged in user's name - so that the added fields are linked to the connected user.

How do I manage that?

&nbsp;

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![ZapBaum60976](https://avatars.discourse-cdn.com/v4/letter/z/8dc957/32.png) [@ZapBaum60976](https://forums.knack.com/u/ZapBaum60976)\
**Post date:** [January 26, 2022, 4:31pm UTC](https://forums.knack.com/t/importing-a-csv-file-using-your-own-code/9231/10 "2022-01-26T16:31:40Z")

</div>

I know this is very old, but does anyone know how to change this from object-based to view-based?

---

<div class="post-metadata">

**Author:** ![KnackPros](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/knackpros/32/807_2.png) [@KnackPros](https://forums.knack.com/u/KnackPros)\
**Post date:** [January 27, 2022, 6:06am UTC](https://forums.knack.com/t/importing-a-csv-file-using-your-own-code/9231/11 "2022-01-27T06:06:15Z")

</div>

To change this into a View-Based request, you can change the **ajax** code:

1. Change the **url** to a view in your app:

```auto
https://api.knack.com/v1/pages/scene_xx/views/view_yy/records

```

1. Inside the **headers** , set `Content-Type` to `application/json` and set `X-Knack-REST-API-Key` to `knack`. If the view is nested under a login, then set `Authorization` to a [user token](https://docs.knack.com/docs/user-tokens) valid for the view.

Hope that helps. You can learn more about [View-Based Requests](https://docs.knack.com/docs/view-based-post) in the Knack docs.

If you ever need professional assistance feel free to reach out.

Thanks,  
Ian  
[Knack Pros](https://knackpros.com)

---

<div class="post-metadata">

**Author:** ![Colin](https://avatars.discourse-cdn.com/v4/letter/c/e19b73/32.png) [@Colin](https://forums.knack.com/u/Colin)\
**Post date:** [February 20, 2022, 3:05am UTC](https://forums.knack.com/t/importing-a-csv-file-using-your-own-code/9231/12 "2022-02-20T03:05:16Z")

</div>

Hi Peter… thanks for this code. It works well. I have a further question about this and hoping you could extend further help. All user imports data into a single object in my app. However users should only able to view thei imported data .This can be facilitated by the connection field of the user account in the object which will display the users name. Is ther a way to get this connection field to display the name of the user on an import ?

Br Colin

---

<div class="post-metadata">

**Author:** ![Colin](https://avatars.discourse-cdn.com/v4/letter/c/e19b73/32.png) [@Colin](https://forums.knack.com/u/Colin)\
**Post date:** [February 20, 2022, 3:20am UTC](https://forums.knack.com/t/importing-a-csv-file-using-your-own-code/9231/13 "2022-02-20T03:20:53Z")

</div>

Hi , wondering if you found a solution? I have the same query

---

<div class="post-metadata">

**Author:** ![ZapBaum60976](https://avatars.discourse-cdn.com/v4/letter/z/8dc957/32.png) [@ZapBaum60976](https://forums.knack.com/u/ZapBaum60976)\
**Post date:** [February 22, 2022, 12:39pm UTC](https://forums.knack.com/t/importing-a-csv-file-using-your-own-code/9231/14 "2022-02-22T12:39:27Z")

</div>

Thanks Ian!

---

<div class="post-metadata">

**Author:** ![ZapBaum60976](https://avatars.discourse-cdn.com/v4/letter/z/8dc957/32.png) [@ZapBaum60976](https://forums.knack.com/u/ZapBaum60976)\
**Post date:** [February 22, 2022, 12:47pm UTC](https://forums.knack.com/t/importing-a-csv-file-using-your-own-code/9231/15 "2022-02-22T12:47:59Z")

</div>

Hi Colin,

I managed to get this to work - if you use the View-based approach, you can add record rules in the form (which is used to create the records on csv import) and set the rules to update the logged-in user, etc.  
Let me know if this makes - took me forever to figure out how to do view-based requests 😉
