QBFC: Specify custom field data when adding new customer (Custom field already exists) - intuit-partner-platform

I am running some tests to specify a value for a custom field that is already setup in quickbooks.
I cana dd the customer, but I fail to add the custom field... I think I have an issue # "FullName" in the last DataExtMod line...
Any ideas on this? I get no specific error, just an hresult.
Dim custAdd As ICustomerAdd = qbMsgReq.AppendCustomerAddRq
Dim str_name As String = "Louis Pluto Test 2 - ZA Code"
Dim str_phone As String = "0764128111"
custAdd.Name.SetValue(str_name)
custAdd.Phone.SetValue(str_phone)
custAdd.Email.SetValue("email#addy.com")
custAdd.FirstName.SetValue("myname")
custAdd.LastName.SetValue("my lastname")
custAdd.fullname.setvalue()
'add custom ID field...
Dim MyDataExtMod As IDataExtMod
MyDataExtMod = qbMsgReq.AppendDataExtModRq
MyDataExtMod.OwnerID.SetValue("0")
MyDataExtMod.DataExtName.SetValue("ID NUMBER")
MyDataExtMod.DataExtValue.SetValue("0123456789012")
MyDataExtMod.ORListTxn.ListDataExt.ListDataExtType.SetValue(ENListDataExtType.ldetCustomer)
MyDataExtMod.ORListTxn.ListDataExt.ListObjRef.FullName.SetValue(str_name)
UPDATE
My XML Responce:
MyDataExt_resp.ToXMLString "<?xml version="1.0" ?> <QBXML> <QBXMLMsgsRs> <CustomerAddRs requestID="0" statusCode="0" statusSeverity="Info" statusMessage="Status OK"> <CustomerRet> <ListID>8000051D-1369767881</ListID> <TimeCreated>2013-05-28T21:04:41+02:00</TimeCreated> <TimeModified>2013-05-28T21:04:41+02:00</TimeModified> <EditSequence>1369767881</EditSequence> <Name>Louis Test User with ID2</Name> <FullName>Louis Test User with ID2</FullName> <IsActive>true</IsActive> <Sublevel>0</Sublevel> <FirstName>Louis</FirstName> <LastName>van Tonder</LastName> <Phone>0123456789</Phone> <Email>email#addy.com</Email> <AdditionalContactRef> <ContactName>Main Phone</ContactName> <ContactValue>0123456789</ContactValue> </AdditionalContactRef> <AdditionalContactRef> <ContactName>Main Email</ContactName> <ContactValue>email#addy.com</ContactValue> </AdditionalContactRef> <Balance>0.00</Balance> <TotalBalance>0.00</TotalBalance> <JobStatus>None</JobStatus> </CustomerRet> </CustomerAddRs> <DataExtModRs requestID="1" statusCode="3120" statusSeverity="Error" statusMessage="Object "ID NUMBER" specified in the request cannot be found. QuickBooks error message: This feature is not enabled or not available in this version of QuickBooks." /> </QBXMLMsgsRs> </QBXML> " String
This part is obviously interesting... the custom field is just "ID NUMBER" , should I reference it in some other way? Naming convention?
<DataExtModRs requestID="1" statusCode="3120" statusSeverity="Error" statusMessage="Object "ID NUMBER" specified in the request cannot be found. QuickBooks error message: This feature is not enabled or not available in this version of QuickBooks." /> </QBXMLMsgsRs>

The FullName you set in your DataExt should be the same as the FullName for the customer you're creating. Otherwise, you'll be telling QuickBooks to set the custom field for some other random object.
e.g. if this is the FullName of your customer:
Dim str_name As String = "Louis Pluto Test 2 - ZA Code"
Then you should use that same FullName in your DataExt:
' This is *wrong*:
MyDataExtMod.ORListTxn.ListDataExt.ListObjRef.FullName.SetValue("Myname mylastname")
' This is correct:
MyDataExtMod.ORListTxn.ListDataExt.ListObjRef.FullName.SetValue(str_name)

Related

Automate Outlook Emails with Attachments in Excel

I have an Excel spreadsheet with the following 5 columns:
Invoice Number, 2) Company, 3) Primary Email address, 4) Secondary Email address(es), 5) Account Number
I also have a folder that contains invoices. Each invoice has the invoice number in its file name -- i.e., Inv_123456.pdf
I want to build an excel macro that -- when I provide a list of invoice number(s) will:
Open an email -- To: <Primary Contact, Cc: <Secondary contacts, and Bcc: <me,
Put the Invoice Number in the subject, and
Go to the folder containing the invoices and attach the corresponding invoice named InvNo_*.pdf, i.e., InvNo_123456.pdf
This is repeated for each invoice number and the email is displayed for review. *Initially, I want to display the email w/attachment until I am comfortable the macro works as expected.
The path to the folder containing the pre-filled invoices is --
C:\Users\christma-2\OneDrive - OurYear2Win\Documents\Clorodet\Invoice Emails\Attachments\Invoice_*.pdf
Following is the macro I've created so far. I would like to pull the invoice with the corresponding invoice number and attach it to the email.
Sub Send_Email_to_List()
Dim OL As Object, MailSendItem As Object
Dim MsgTxt As String
Set OL = CreateObject("Outlook.Application")
For Each xCell In ActiveSheet.Range(Range("C1"), Range("C" & Rows.Count).End(xlUp))
user_email = xCell.Value
user_subject = "Subject Line for the Email"
user_msg = "Thank You For Submitting this email"
Set MailSendItem = OL.CreateItem(olMailItem)
With MailSendItem
.Subject = user_subject
.Body = user_msg
.To = user_email
.CC = " "
.Bcc = "clorodet20607#aol.com"
'I need help getting the correct attachment, putting the invoice number in the subject, and cc'ing the secondary contacts
.Attachments.Add ("C:\Users\christma-2\OneDrive - OurYear2Win\Documents\Clorodet\Invoice Emails\Attachments\W1\???.pdf")
.Display
End With
Next xCell
Set OL = Nothing
End Sub
Find the corresponding contact's email address -- To: <Primary Contact, Cc: <Secondary contacts, and Bcc: <me,
You can use the CreateRecipient method creates a Recipient object. The name of the recipient; it can be a string representing the display name, the alias, or the full SMTP email address of the recipient. So, there is no need to search for the contact.
Sub ResolveName()
Dim myNamespace As Outlook.NameSpace
Dim myRecipient As Outlook.Recipient
Dim CalendarFolder As Outlook.Folder
Set myNamespace = Application.GetNamespace("MAPI")
Set myRecipient = myNamespace.CreateRecipient("Eugene Astafiev")
myRecipient.Resolve
If myRecipient.Resolved Then
Call ShowCalendar(myNamespace, myRecipient)
End If
End Sub
Sub ShowCalendar(myNamespace, myRecipient)
Dim CalendarFolder As Folder
Set CalendarFolder = myNamespace.GetSharedDefaultFolder(myRecipient, olFolderCalendar)
CalendarFolder.Display
End Sub
You can get a Contact instance by using the following sequence of calls:
recipient.AddressEntry.GetContact()
The Outlook object model supports three main ways of customizing the message body:
The Body property returns or sets a string representing the clear-text body of the Outlook item.
The HTMLBody property of the MailItem class returns or sets a string representing the HTML body of the specified item. Setting the HTMLBody property will always update the Body property immediately. For example:
Sub CreateHTMLMail()
'Creates a new e-mail item and modifies its properties.
Dim objMail As Outlook.MailItem
'Create e-mail item
Set objMail = Application.CreateItem(olMailItem)
With objMail
'Set body format to HTML
.BodyFormat = olFormatHTML
.HTMLBody = "<HTML><BODY>Enter the message text here. </BODY></HTML>"
.Display
End With
End Sub
The Word object model can be used for dealing with message bodies. See Chapter 17: Working with Item Bodies for more information.
Note, the MailItem.BodyFormat property allows you to programmatically change the editor that is used for the body of an item.

Can't autopopulate fields when adding new record - "You can't assign value to this object"

I am trying to make a form where I would enter new data. I am trying to make a combobox which would when I press selected record autofill data in form with known data. So I have Owner [Vlasnik] table and I am able to autofill info about owner but I am not able to change ID_VU which is unique key for each owner.
Private Sub cboID_VU2_Change()
Me.[Vlasnik.ID_VU].Value = Me.cboID_VU2.Column(0)
Me.[Naziv tvrtke].Value = Me.cboID_VU2.Column(1)
Me.[Ime korisnika].Value = Me.cboID_VU2.Column(2)
Me.[Prezime korisnika].Value = Me.cboID_VU2.Column(3)
Me.[Adresa korisnika].Value = Me.cboID_VU2.Column(4)
Me.[Telefon].Value = Me.cboID_VU2.Column(5)
Me.Mail.Value = Me.cboID_VU2.Column(6)
End Sub
Control source of comobox is empty and this is rowsource :
SELECT Vlasnik.ID_VU, Vlasnik.[Naziv tvrtke], Vlasnik.[Ime korisnika], Vlasnik.[Prezime korisnika], Vlasnik.[Adresa korisnika], Vlasnik.Telefon, Vlasnik.Mail FROM Vlasnik ORDER BY Vlasnik.[Prezime korisnika];
When I try to run a code I am getting error on line
Me.[Vlasnik.ID_VU].Value = Me.cboID_VU2.Column(0)
with message "You can't assign value to this object"
I think problem is that Vlasnik.ID_VU is set as autonumber

Redemption in MS Access / Outlook (trying to include a separate message file in email)

This code is in MS Access (2010) VBA, using the Redemption library with Microsoft Outlook 2010.
I had this process working before, but we recently had a Citrix upgrade that I guess reset something in my Outlook and now the process no longer works.
I have a folder of .msg files which are basically pre-made email templates with all the proper formatting, images, text, etc.
This is what I was doing before:
Dim outlookApp As Object, namespace As Object
Dim oItem, MyItem
Set outlookApp = CreateObject("Outlook.Application")
Set namespace = outlookApp.GetNamespace("MAPI")
namespace.Logon
Set MyItem = outlookApp.CreateItemFromTemplate(path_to_dot_msg_file)
'And then there are many calls like this:
MyItem.HTMLBody = Replace(MyItem.HTMLBody, "Dear Person,", "Dear " & name)
'...
Set safeItem = CreateObject("Redemption.SafeMailItem")
Set oItem = MyItem
safeItem.Item = oItem
'this next line displays the email, and as of this line, it looks correct
'safeItem.Display
'but as of this line, the issue occurs
safeItem.HTMLBody = "<p>This is an extra message that shows up before the .msg file</p>" & safeItem.HTMLBody
safeItem.Recipients.ResolveAll
safeItem.Send
Now when the email is sent, the .msg contents aren't present at all -- the only thing that shows up is the "extra message" that I prepended to the HTMLBody.
What do I need to change or update? Is this something I need to change in the code, or in my Outlook settings, etc?
Extra: body insertion:
Function insertStringBodyTag(htmlBody As String, stringToInsert As String)
Dim s As String
Dim i As Integer
s = htmlBody
i = InStr(1, s, "<body")
i = InStr(i, s, ">")
s = Left(s, i) & stringToInsert & Right(s, Len(s) - i)
insertStringBodyTag = s
End Function
'Called with safeItem.htmlBody = insertStringBodyTag(safeItem.htmlBody, prefix_string)
You cannot concatenate 2 HTML strings and expect a valid HTML string back - the two must be merged - find the position of the "<body"substring in the original HTML body, then find the positon of the following ">" (this way you take care of the body element with attributes), then insert your HTML string following that ">".

Ms Access - Button with code doesn't work to send email

I have this code set in access, but no email is sending upon clicking the button on the form. I have outlook open. When i click the button on the form, i can't see anything that actually happens. I want the email address to be equal to the value in [text1], and I am trying to make the subject include a fixed message plus the input from [text2]. Even without these variables, I can't get this to work
Public Sub Command495_Click()
Dim mailto As String
Dim ccto As String
Dim bccto As String
mailto = [text1]
ccto = ""
bccto = ""
emailmsg = "trial"
mailsub = [text2] & ", Does this work?"
On Error Resume Next
DoCmd.SendObject acSendNoObjectType, , acFormattxt, mailto, ccto, bccto, mailsubj, emailmsg, True
End Sub
I have checked to make sure the onclick property shows event procedure. I am stuck, please help!
Here are a few suggestions and a modified version of your code.
ALWAYS use Option Explicit and compile your module before testing. You had a number of variables that were not defined and incorrect spelling of some options.
NEVER bypass errors when testing (get rid of your "On Error Resume Next") That's why you never saw an error.
Look for every place I entered ">>>" and address that issue.
Always explicitly define your variables and use the proper Type. Removes all doubt of what/where something is.
Option Compare Database
Option Explicit
Public Sub Command495_Click()
Dim mailto As String
Dim ccto As String
Dim bccto As String
Dim emailmsg As String
Dim mailsub As String
mailto = [Text1] ' >>> Where is [Text1]?? Remove for testing
ccto = ""
bccto = ""
emailmsg = "trial"
mailsub = [Text2] & ", Does this work?" ' >>> Where is [Text2]?? Remove for testing
' >>> Bad idea to ignore errors when testing!!
On Error Resume Next
'>>> Following line had: (1) 'acSendNoObjectType' which is incorrect; (2) mailsubj, which is undefined
DoCmd.SendObject acSendNoObject, , acFormatTXT, mailto, ccto, bccto, mailsub, emailmsg, True
End Sub

How to set internal names of new SharePoint fields with PowerShell?

I'm trying to add a new field to a SharePoint list and set its internal name. I have both the static name and display name specified but I can't figure out why the internal name gets set as First_x0020_Name.
$web = Get-SPWeb 'https://server'
$list = $web.Lists['listName']
$newFieldXML = '<Field Type="Text" StaticName="FirstName" DisplayName="First Name"></Field>'
$list.Fields.AddFieldAsXml($newFieldXML)
This simply works for me-
XML should be of format:
$newFieldXML = '<Field Type="Text" Name="FirstName" StaticName="FirstName" DisplayName="First Name"></Field>'
In PowerShell use [Microsoft.SharePoint.SPAddFieldOptions]::AddFieldInternalNameHint as third parameter of AddFieldAsXml function
$spListFields = $spList.Fields.AddFieldAsXml($newFieldXML, $true, [Microsoft.SharePoint.SPAddFieldOptions]::AddFieldInternalNameHint)
It looks like AddFieldAsXml cannot be used to set the internal name
According to the article, if you want to use AddFieldAsXml to set the internal name you need to:
Define your CAML so that the Internal Name you want to use is
actually set as the Display Name
Create the field with the call to AddFieldAsXml
After the field is created, retrieve it using the internal name and set the Title property to the real Display Name you wanted it to
be in the first place
You need two additional steps: retrieve the field and set the internal name
Use:
$list.Fields.AddFieldAsXml($newFieldXML, $true,[Microsoft.SharePoint.SPAddFieldOptions]::AddFieldInternalNameHint)
instead of
$list.Fields.AddFieldAsXml($newFieldXML)
Refer this link
RESOLVED:
Please check below post for the Answer:
Set Field Internal Name For New Fields
Sample Code:
Please use [Microsoft.SharePoint.Client.AddFieldOptions]::AddFieldInternalNameHint
$fieldXml="<Field Type='Text' DisplayName='"+ $Field_DisplayName +"'
Required='"+$Field_Required+"' MaxLength='255'
StaticName='"+$Field_InternalName+"' Name='"+$Field_InternalName+"' />
$spoList.Fields.AddFieldAsXml($fieldXml,$true,[Microsoft.SharePoint.Client.AddFieldOptions]::AddFieldInternalNameHint)
$spoList.Update()
$clientContext.ExecuteQuery()
You can use this script to create fields with internal name and then update the display name.
$web = Get-SPWeb 'https://server'
$list = $web.Lists['listName']
$newFieldXML = '<Field Type="Text" StaticName="FirstName"
DisplayName="FirstName"></Field>'
$list.Fields.AddFieldAsXml($newFieldXML)
$fld = $list.Fields["FirstName"]
$fld.Title = "First Name"
$fld.Update();
You can't change the internalName of a field after his creation.
If you use XML to create field :
The internalName of field is set with the Attribute : "Name"
so your field XML defintion should be :
$newFieldXML = '<Field Type="Text" Name="FirstName" StaticName="FirstName" DisplayName="First Name"></Field>'