11 Replies Latest reply on Sep 27, 2011 11:23 AM by philmodjunk

    Import Script Not Working.

    bablahemen

      Title

      Import Script Not Working.

      Post

       Hello,

      I being trying to import records from DB1 ro DB2 by calling an script.

      DB1 have 2 Table, T1 & t2. both have relationship with each other.

      Same DB 2 also have T1 & T2.

      DB1 - T1 contains data of customer info. and T2 contains what product will he buy.

      i am facing an problem on importing the records related to T1 - Record ID from T2, to DB2 - T2. its import all the records. which ever are created new also the old one.

      in the script i have omited the current record which i want to import. but when importing the records from T1 get perfectly imported but from T2 its not. its import all the records related to T1 records in DB2 which are already imported

      i have attached an image file of the script.

      please anyone can help me !!!

      ImportScript.png

        • 1. Re: Import Script Not Working.
          philmodjunk

          What Value are your trying to enter into Quotation::K_ID_Quote?

          The current set field step you have highlighted above specifies this field as the target field, but lacks any calculated result whith which to store in the field. There should be a second parameter in this step separated by a semi-colon (;).

          • 2. Re: Import Script Not Working.
            bablahemen
             No i dont want to insert any value, i set the field bcus i want to import that record only. I want an script where i can import only the selected record.
            • 3. Re: Import Script Not Working.
              philmodjunk

              That's not what set field does. You can remove this script step.

              If you want to import only that record, You must isolate it in a found set of just that record--which is what your omit records, show omitted only is supposed to do, but should be written as:

              Show All Records
              Omit Records
              Show Omitted Only

              Without the Show All records step, the Show Omitted Only step will bring back the current record and all records not currently in the found set, which could be all the records in your table.

              You can remove these steps altogether if your Go TO Related Records step will only match to a single record in the Quotation Table.

              Any time you use Go To Related Records like this, you should include code to check and see if any related records exist or trap for an error after the GTRR step. If there are no related records in Quotations for the current record wherever you are when that script step executes, the script will continue, but stays on the current layout and any further script steps execute from that context--which can have very undesirable consequences for you.

              Here's one method:

              Add this step after the GTRR step:

              If [ Not Get ( LastError ) ]

                 #put all steps after the Go To Related Records step here
              End IF

              • 4. Re: Import Script Not Working.
                bablahemen
                Sorry but can u edit or give me an script bcus i didnt got ur point on where to put the omit records & the if clause.
                • 5. Re: Import Script Not Working.
                  philmodjunk

                  I don't think you should have any of these steps, Remove them from your script, if you can confirm that the relationship in Go To Related Records matches to one and only one record:

                  Omit Records
                  Show Omitted only

                  also remove the set field step as it does nothing here.

                  If you had posted your script as text, I would have copied, edited and pasted the updated version here, but am very pressed for time so don't choose to retype your entire script here.

                  Now just add the If step immediately after your Go To Related Records step. It use Get (LastError) to check and see if the Go To Related Records step actually found a matching record or not.

                  • 6. Re: Import Script Not Working.
                    bablahemen

                    HI Phil,

                    I tried the way u said but the go to pointer doesnt point to the related record which i want to import. can u help me. i have the script below for modification.

                     

                     Show Custom Dialog [ Title: "Generate SI"; Message: " Do you want to continue creating SI? If yes then kindly click ok else please check andmake SI."; Buttons: “OK”, “Cancel” ]

                    If [ Get ( LastMessageChoice ) = 1 ]

                    Commit Records/Requests[ Skip data entry validation; No dialog ]

                    Allow User Abort [ Off ]

                     Go to Related Record [ From table: “Quotation”; Using layout: <Current Layout> ][ Show only related records ]

                    If [ Get ( LastError ) >0 ]

                     Show All Records

                    Omit Record

                     Show Omitted Only

                     Perform Script [ “Import Quote” from file: “HAA-SI” ]

                     Show Custom Dialog [ Title: "Generate SI"; Message: "SI Generated, aprroved from account for delivery."; Buttons: “OK”, “Cancel” ]

                     Else

                    Show Custom Dialog [ Title: "Generate SI"; Message: "NO Records Found."; Buttons: “OK”, “Cancel” ]

                     Go to Layout [ “Quotation View Screen ” (Quotation) ]

                    Exit Script [ ]

                     End If

                    Set Field [ Quotation::QuoteStatus; "Quote Win. SI Prepared." ]

                    Set Field [ Quotation::QuoteOC; "CLOSED" ]

                     Perform Script [ “Go to Record List” ]

                     Else

                    Go to Layout [ “Quotation View Screen ” (Quotation) ]

                    Exit Script [ ]

                    End If

                    • 7. Re: Import Script Not Working.
                      philmodjunk

                      Show Custom Dialog [ Title: "Generate SI"; Message: " Do you want to continue creating SI? If yes then kindly click ok else please check and
                                                       make SI."; Buttons: “OK”, “Cancel” ]
                      If [ Get ( LastMessageChoice ) = 1 ]
                             Commit Records/Requests[ Skip data entry validation; No dialog ]
                             Allow User Abort [ Off ]
                             Go to Related Record [ From table: “Quotation”; Using layout: ][ Show only related records ]
                             If [ Get ( LastError ) = 0 ]
                                     Perform Script [ “Import Quote” from file: “HAA-SI” ]
                                     Show Custom Dialog [ Title: "Generate SI"; Message: "SI Generated, aprroved from account for delivery."; Buttons: “OK”, “Cancel” ]
                             Else
                                     Show Custom Dialog [ Title: "Generate SI"; Message: "NO Records Found."; Buttons: “OK”, “Cancel” ]
                                     Go to Layout [ “Quotation View Screen ” (Quotation) ]
                                     Exit Script [ ]
                             End If
                             Set Field [ Quotation::QuoteStatus; "Quote Win. SI Prepared." ]
                             Set Field [ Quotation::QuoteOC; "CLOSED" ]
                             Perform Script [ “Go to Record List” ]
                      Else
                             Go to Layout [ “Quotation View Screen ” (Quotation) ]
                             Exit Script [ ]
                      End If

                      And you may want to move the text in blue to be located just after the Show Custom Dialog [Title: "generate SI"...] step, but I leave that decision up to you.

                      I'm making some assumptions about your relationships that may not be correct here. I am assuming that the relationship used in the Go To Related Record step matches to one and only one record. If so,

                      Show All Records
                      Omit Record
                      Show Omitted Only

                      Is not needed as the Go to related records step will produce a found set of just the one record anyway. In your original script, where you only had Omit Record/Show Omitted Only, the script pulled up this one record, then omitted it, creating an empty found set with all records in the "omitted" set. Then Show Omitted Only brought up all records into the found set and this is what was imported by your script.

                      Let me know if this still doesn't work for you.

                      • 8. Re: Import Script Not Working.
                        bablahemen

                         Sorry Phil but the script is not work.

                        The GTRR works only for the T1, but not for T2. and even if i set an pointer to show reocrds from Line item table or quotation, its doent work.

                         

                        • 9. Re: Import Script Not Working.
                          philmodjunk

                          You may need to explain that in more detail.

                          T2 is "Quotation"?

                          T1 is a customer contact table?

                          That's my guess here....

                          You are importing from "Quotation" in one file to "Quotation" in another?

                          That's all the current script sets up before calling the Import script in the second file. there is no part of your code that sets up records in T1 for import into T1 in the second file, thus, if the script in the second file: "Import Quote" also has an import records step that imports from T1 as well as a step to import T2, it will import the current found set of whatever table occurrence in your first file that the Import Records step specifies as the source table. It should specify the source table and you would add some steps to the beginning of your script to isolate the current record in a found set of just that record.

                          Show All Records
                          Omit Record
                          Show Omitted Only

                          Will work if this is a single user file, but can fail if other users might be creating new records in T1 at the same time that you run this script. If this is a possibility, perform a find to isolate the current record. I'll assume you have a field with a serial number that uniquely identifies each record in T1 named: __pk_CustomerID:

                          Set Variable [$ID ; value: T1::__pk_CustomerID ]
                          Enter Find Mode [] //clear the pause check box
                          Set Field [T1::__pk_CustomerID ; $ID]
                          Perform Find []

                          Whichever method you choose to use, insert these steps right after: If [ Get ( LastMessageChoice ) = 1 ]

                          • 10. Re: Import Script Not Working.
                            bablahemen

                            Hi Phil

                            The script is not working, as the related records in another table is not getting omited. i have taken some screenshots but cant fiqure out how i post in this currnt post. can i have ur email so that i can send it. 

                            Hemen

                            • 11. Re: Import Script Not Working.
                              philmodjunk

                              You can click edit_post to upload an image to your original post at the top of this screen. Since you already have an image uploaded there, you'd need to do the following:

                              1) click Edit post and delete the current image. Then click save.

                              2) Click edit post again and upload the new image.

                              This avoids problems caused by a bug in the RightNow software that can keep other users from seeing your new image if you use the replace option instead of the above 2 step process.

                              You can also upload a file to a file sharing site and then post a link to it in any post you make to this forum.