/// <summary> /// Demonstrates updating a Custom Object record and Inserting a new one /// For more information, please see... /// https://help.production.membersuite.com/hc/en-us/articles/115002960103-System-Overview-Configuration-How-To-Create-a-Custom-Object /// https://help.production.membersuite.com/hc/en-us/articles/115002985646-System-Overview-Configuration-Reference-Create-a-Custom-Object-Field-Descriptions /// https://help.production.membersuite.com/hc/en-us/articles/115002985666-System-Overview-Configuration-Custom-Objects /// https://help.production.membersuite.com/hc/en-us/articles/115002985586-System-Overview-Configuration-How-To-Edit-a-Custom-Object /// https://help.production.membersuite.com/hc/en-us/articles/115002986266-System-Overview-Configuration-How-To-Delete-a-Custom-Object /// </summary> private static void UpdateCustomObjects() { using (var api = ConciergeAPIProxyGenerator.GenerateProxy()) { var cusObjSearch = new Search("FakeCustomObject__c"); //You'll need to create your own objects for this to work cusObjSearch.AddCriteria(Expr.Equals("Owner.LocalID", 101292)); //In this example, the FakeCustomObject derives from the Individual Object. So we are using the Owner.Local to query the Individual's LocalID and get back a specific FakeCustomObject record var cusObjResult = api.GetObjectBySearch(cusObjSearch, null); if (cusObjResult.ResultValue != null) //Update existing record { var mso = new MemberSuiteObject(); mso.Fields["CompanyName__c"] = "TestCompany4"; mso.Fields["Description__c"] = "This is a test"; mso.Fields["Website__c"] = "www.test.com"; mso.Fields["Name"] = "test Trans"; mso.Fields["Owner"] = cusObjResult.ResultValue; var saveResult = api.Save(mso); } else //Insert new record { var meta = api.DescribeObject("FakeCustomObject__c").ResultValue; var instance = MemberSuiteObject.FromClassMetadata(meta).ConvertTo <msCustomObjectInstance>(); instance.Owner = cusObjResult.ResultValue.Fields["ID"].ToString(); instance.Fields["CompanyName__c"] = "TestCompany4"; instance.Fields["Description__c"] = "This is a test"; instance.Fields["Website__c"] = "www.test.com"; instance.Fields["Name"] = "test Trans"; var insertResult = api.Save(instance); } } }
public static MemberSuiteObject CreateNewObject(string className) { return(MemberSuiteObject.FromClassMetadata(DescribeObject(className))); }
public override void Run() { /* This sample is going to login to the association and create a record with a name, * email, and birthday that you specify. Once saved, the system will display the ID * of the individual created, the age (which MemberSuite calculates), and will automatically * launch the 360 view of that record in the web browser */ // First, we need to prepare the proxy with the proper security settings. // This allows the proxy to generate the appropriate security header. For more information // on how to get these settings, see http://api.docs.membersuite.com in the Getting Started section if (!ConciergeAPIProxyGenerator.IsSecretAccessKeySet) { ConciergeAPIProxyGenerator.SetAccessKeyId(ConfigurationManager.AppSettings["AccessKeyID"]); ConciergeAPIProxyGenerator.SetSecretAccessKey(ConfigurationManager.AppSettings["SecretAccessKey"]); ConciergeAPIProxyGenerator.AssociationId = ConfigurationManager.AppSettings["AssociationID"]; } // ok, let's generate our API proxy using (var api = ConciergeAPIProxyGenerator.GenerateProxy()) { // now, we want to create a new individual // First, we need to get a description of the individual // The description will tell the client SDK how to "build" the object; in other words, what the fields are // and what the default values are. So if you set a default value for LastName to 'Smith', the Describe // operation will have that in the metadata. When you construct the object, it will then have the last name // defaulted to 'Smith' ClassMetadata meta = api.DescribeObject("Individual").ResultValue; // now, create our MemberSuiteObject MemberSuiteObject mso = MemberSuiteObject.FromClassMetadata(meta); /* it's always easier to use the typed MemberSuiteObject * * You could just instantiate this directly by saying: * * msIndividual p = new msIndividual(); * * This would work - but without the class metadata, the object would not respect any of the defaults * that are set up. It would be a totally blank object.*/ msIndividual person = mso.ConvertTo <msIndividual>(); // now, you don't have to use dictionaries and string keys, you can access the object directly Console.WriteLine("Please enter a first name and press ENTER."); person.FirstName = Console.ReadLine(); Console.WriteLine("Please enter a last name and press ENTER."); person.LastName = Console.ReadLine(); person.EmailAddress = "*****@*****.**"; Console.WriteLine("Please enter a birthdate and press ENTER."); string date = Console.ReadLine(); DateTime dob; if (!DateTime.TryParse(date, out dob)) { Console.WriteLine("Invalid birthdate... exiting..."); return; } person.DateOfBirth = dob; // ok, so we can save this now var result = api.Save(person); if (!result.Success) { throw new ApplicationException("Unable to save: " + result.FirstErrorMessage); } msIndividual newPerson = result.ResultValue.ConvertTo <msIndividual>(); Console.WriteLine("Successfully saved individual #{0} - {1}. Age is {2}. ", newPerson.LocalID, newPerson.Name, newPerson.Age); Console.WriteLine("URL is:"); Console.WriteLine("https://console.production.membersuite.com/app/console/individual/view?c=" + newPerson.ID); } }