Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I would like to add some code behind on form load. I will be calling web services to populate few drop downs, Like department, manager, etc.

Is that the best approach to do this? or Should I consider another way.

Also, I dont want to hard code the webapplication in the code. Could this be automatically picked up by the code? or What I take this http://msdn.microsoft.com/en-us/library/office/ff961895 approach then would the publishing to a new farm (because we have 4 different farm) automatically resolve the target farm address. I hope I am making sense.

May I please have your 2 cents on this.

share|improve this question

2 Answers 2

The context of your question is too vague and the the answer depends on dozens of factors.

IMO, the best approach is to avoid custom code in Infopath forms and I could not find anything that cannot be done without coding. Also, the coding in Infopath is not hard or manually written but constructed through Infopath Designer GUI.

Update:
For example, I have a filled ClientList with ClientName column

Fig.1. ClientList with ClientName column (screenshot from browser)

Fig.1. ClientList with ClientName column (screenshot from browser)

In Infopath Designer I create an Infopath form and put on designer surface Drop-Down List Box control, click on it and press Alt+Enter to open it properties.

There, under Data tab, against I choose "Get choices from an external data source" and press add press "Add..." button against "Data Source:"

Fig.2. Starting data connection wizard for Drop-Down List box in Infopath Designer 2010

Fig.2. Starting data connection wizard for Drop-Down List box in Infopath Designer 2010

Note that data connection can be created separately by a dozen of variants

Fig.3. Step2 of Data Connection Wizard "Select the source of your data"

Note that you could have selected different sources including:

  • REST Web Service
  • SOAP Web Service
  • etc.

Fig.3. Step2 of Data Connection Wizard "Select the source of your data"

Fig.4. Step3 of Data Connection Wizard "Sharepoint site details"

Fig.4. Step3 of Data Connection Wizard "Sharepoint site details"

Fig.5. Step4 of Data Connection Wizard "The Sharepoint site site that you slected has the following lists and libraries you can use as your data connection"

Fig.5. Step4 of Data Connection Wizard "The Sharepoint site site that you slected has the following lists and libraries you can use as your data connection"

Fig.6. Step5 of Data Connection Wizard "The Sharepoint list has the following fields you can can select from"

Fig.6. Step5 of Data Connection Wizard "The Sharepoint list has the following fields you can can select from"

Running it:

Fig.7. Running Infopath form with Drop-Down List Box linked to a column ClientList of ClientList list

Fig.7. Running Infopath form with Drop-Down List Box linked to a column ClientList of ClientList list

share|improve this answer

Roman,

I know what you are asking. Basically, I want to create a form Generic enough that i can be moved from farm to farm (say QC to Production, etc.). And you don't want to open infopath form in design to make those changes. See the Url below and it might help with your situation. Basic idea is to use "Data Connection Library".

http://blueinfopath.blogspot.com/2009/06/prepare-your-infopath-for-deployment.html

http://msdn.microsoft.com/en-us/library/office/gg435970.aspx

share|improve this answer
    
-1 Your answer is unrelated even to changed by you question and BTW they are not applicable to Infopath forms of type/compatibility "Sharepoint List Form" or "Workflow Form" where Main Data Connections are automatically created as unmodifiable, cannot be created manually or by wizard or from data connection file, cannot be accessed, changed, saved as file or re-utilized. –  Gennady Vanin Геннадий Ванин Aug 3 '12 at 18:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.