Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

How to save more than one data in one form in crm 2015

Posted on by 260

crm_2D00_wanted.jpg

In crm 2015 i have a form. In this form i save one firm (that can be choosen from lookup field),the period(option set),amount,another optionset value,invoice number,date and mark(comes from the choosen firm field. A firm has a mark number)
When i save this form it saves these information to the sql database cooresponding table and fills one row. The guid id of the firm that is choosen from the lookup field is saved to the database table.
Up to now everything is ok.
I wrote a html web service to see all firms as checkboxes. The user can select more than one firm. When the user press the button the selected firms(with thier guid and mark numbers) are send to the parent form.
I send them seperate multiline textbox. Now i want to save these firms one by one with their info (mark number,guid ) to the same sql database table as seperated rows. I mean if 3 firms are selected it shpoul be save to the databesa as 3 rows and
each row has its firm and infos about this firm.
The other fields on the form like invoice number etc. are same. I show the form picture also in the question.

How can i do this can anyone help me please .

*This post is locked for comments

  • altun8tr Profile Picture
    altun8tr 260 on at
    RE: How to save more than one data in one form in crm 2015

    I wrote a plugin to do what i need and registered it . After that point how can i use it in this page? I show my code below which is in the plugin. Especially i do not know if i wrote correct code. When user selects more than one firm;after save(kaydet) button press, the records wiil be saved to the database table one row after another. Only the guid of the firm will change, The other infos are the same. I mean if 3 firms selected from the checkboxes. 3 rows with different guids of firm are saved to the database table with same infos(fatura no, marka etc.)

    Can you help me about these. I wrote my firs plugin and will use in crm form. I have to to this because the future of my job belongs to this.

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using System.Threading.Tasks;

    using Microsoft.Xrm.Sdk;

    using Microsoft.Xrm.Sdk.Query;

    namespace CheckboxMagazaKaydet

    {

        public class MyPlugin : IPlugin

       {

           public void Execute(IServiceProvider serviceProvider)

           {

               IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

               ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));

               if ("Create,Update".Contains(context.MessageName) == false) return;

               if (!context.InputParameters.Contains("Target") || (context.InputParameters["Target"] is Entity) == false) return;

               Entity entity = (Entity)context.InputParameters["Target"];

               if (entity.LogicalName != "new_destek_yerelreklam_detay") return;

               try

               {

                   var factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));

                   var service = factory.CreateOrganizationService(context.UserId);

                   if (context.InputParameters != null)

                   {

                       Entity reklamentity = new Entity("new_destek_yerelreklam_detay");

                       if (reklamentity.Attributes.Contains("new_magaza"))

                       {

                           Money tutar = (Money)reklamentity.Attributes["new_tutar"];

                           int faturano = (int)reklamentity.Attributes["new_faturano"];

                           DateTime faturatarihi = (DateTime)reklamentity.Attributes["new_faturatarihi"];

                           string donem = (string)reklamentity.Attributes["new_donem"];

                           int marka = (int)reklamentity.Attributes["new_marka"];

                           reklamentity.Attributes["new_tutar"] = tutar;

                           reklamentity.Attributes["new_faturano"] = faturano;

                           reklamentity.Attributes["new_faturatarihi"] = faturatarihi;

                           reklamentity.Attributes["new_donem"] = donem;

                           reklamentity.Attributes["new_marka"] = marka;

                           //Update

                           service.Update(reklamentity);

                       }

                       else

                       {

                           Guid magazaId = (reklamentity["new_magaza"] as EntityReference).Id;

                           Money tutar = (Money)reklamentity.Attributes["new_tutar"];

                           int faturano = (int)reklamentity.Attributes["new_faturano"];

                           DateTime faturatarihi = (DateTime)reklamentity.Attributes["new_faturatarihi"];

                           string donem = (string)reklamentity.Attributes["new_donem"];

                           int marka = (int)reklamentity.Attributes["new_marka"];

                           reklamentity.Attributes["new_tutar"] = tutar;

                           reklamentity.Attributes["new_faturano"] = faturano;

                           reklamentity.Attributes["new_faturatarihi"] = faturatarihi;

                           reklamentity.Attributes["new_donem"] = donem;

                           reklamentity.Attributes["new_marka"] = marka;

                           service.Create(reklamentity);

                       }

                   }

               }

               catch (Exception ex)

               {

                   throw new InvalidPluginExecutionException(string.Format("ERROR:message:{0}", ex.InnerException != null ? ex.InnerException.Message : ex.Message));

               }

           }

           }

    }

  • Verified answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: How to save more than one data in one form in crm 2015

    Hello,

    I believe you can develop a plugin that will handle Create/Update message and push information from CRM to your external DB. You can start here - crmbook.powerobjects.com/.../developing-a-plug-in

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans