I want to insert a new product on a purchase requisition and edit the Purch Price but the field is read-only.
I try to unlock the field in the PurchReqTable form but it is already locked.
I try to find some run-time method that lock the field, but I was out of luck.
Any idea?
Have a look at the following method in the PurchReqTable Form:
void setFieldAccess()
{
boolean allowEdit = purchReqFormMode == PurchReqFormMode::ShowAll ||
purchReqLine.LineType == PurchReqLineType::Category ||
isUserTaskOwner ||
isUserApprovalOwner;
;
purchReqLine_ds.object(fieldnum(PurchReqLine,PriceUnit)).allowEdit(allowEdit);
purchReqLine_ds.object(fieldnum(PurchReqLine,PurchUnit)).allowEdit(allowEdit);
purchReqLine_ds.object(fieldnum(PurchReqLine,PurchPrice)).allowEdit(allowEdit);
purchReqLine_ds.object(fieldnum(PurchReqLine,LineDisc)).allowEdit(allowEdit);
purchReqLine_ds.object(fieldnum(PurchReqLine,LinePercent)).allowEdit(allowEdit);
purchReqLine_ds.object(fieldnum(PurchReqLine,PurchMarkup)).allowEdit(allowEdit);
purchReqLine_ds.object(fieldnum(PurchReqLine,CurrencyCode)).allowEdit(purchReqLine.RecId != 0);
purchReqLine_ds.object(fieldnum(PurchReqLine,LineAmount)).allowEdit(!purchReqLine.isCatalogItem());
}
Notice how LineAmount is disabled if the current line contains a non-catalog item.
Changing the settings on the datasource or the table will be overridden by this code at runtime. I hope this helps.
Related
self.mb = Menubutton ( self.window2, text="Sound Toggler", relief=RAISED )
self.mb.grid(row=4, column = 0)
self.mb.menu = Menu ( self.mb, tearoff = 0 )
self.mb["menu"] = self.mb.menu
self.ONSound = IntVar()
self.ONSound.set(1)
self.OFFSound = IntVar()
self.OFFSound.set(0)
self.mb.menu.add_checkbutton ( label="ONSound", variable=self.ONSound, command = self.turnON(), onvalue=1,offvalue=0)
self.mb.menu.add_checkbutton ( label="OFFSound", variable=self.OFFSound, command = self.turnOFF(), onvalue=1,offvalue=0)
def turnON(self):
self.ONSound.set(1)
self.OFFSound.set(0)
def turnOFF(self):
self.ONSound.set(0)
self.OFFSound.set(1)
My goal is to turn these two check buttons to toggle sound On and OFF and in doing so only one of these check buttons can be on/off at a single time. Currently this effect is not working and I've been looking at my code for an hour and can't find the problem. Everything shows up when my full program is run but this ON/OFF toggle doesn't work how I want it to.
All help is appreciated,
Thanks
The problem is that you set the command to a function call instead of a funciton reference. This makes the functions run once and assign the return value (None) to command. You should remove the parentheses after the function names.
To make two options of which only one can be selected however, why don't you make them radiobuttons? Then it's as simple as
self.Sound = IntVar()
self.mb.menu.add_radiobutton(label= "ONSound", variable=self.Sound, value=1)
self.mb.menu.add_radiobutton(label="OFFSound", variable=self.Sound, value=0)
How can I set up the if statement so that QTP will display Passed or Failed if conditions met. Currently I have the properties of a valid coupon and invalid coupon. Each will display a different message on the website. Please see the code below:
Set objBrowser = Browser("name:=.*Chico's")
Set objPage = objBrowser.Page("title:=.*Chico's")
Dim x
x=datatable.GetSheet("Global").GetRowCount
'-----for loop---------
For i = 1 To x Step 1
Datatable.SetCurrentRow(i)
objPage.WebEdit("html tag:=INPUT","html id:=claimCodeField","name:=claimCodeField").Set datatable ("Coupon_code", GlobalSheet)
wait 2
objPage.Image("name:=CouponFormHandler","html tag:=INPUT","image type:=Image Button","file name:=btn_apply\.gif").Click
wait 2
objBrowser.Sync
Dim Coupon, Couponerror
xlCoupondescription=dataTable ("Coupon_description", GlobalSheet)
xlInvalid=dataTable("Invalid_coupon", GlobalSheet)
'----Coupon----
Coupon=objPage.WebElement("class:=sb-promo-msg","html tag:=SPAN","html id:=","Index:=1").GetROProperty("outertext")
'----Coupon Error msg-----
Couponerror=objPage.WebElement("class:=sb-error-message","html tag:=DIV","html id:=").GetROProperty("outertext")
'----if statement---------
If (Trim(Coupon) = Trim(xlCoupondescription)) Then
datatable.value("Actual_results", GlobalSheet)="Passed"
If (Trim(Coupon) = Trim(Couponerror)) Then
datatable.value("Actual_results", GlobalSheet)="Failed"
End If
End If
Use the Reporter.ReportEvent method when you want to report custom pass/fail conditions.
import arcpy
fc = r'H:\H-ONUS UTILITY DATA GIS\As_Builts\2014\RandolphPoint_Phase2\789-AS-BUILT 8-7-13.dwg\Polyline'
out_gdb = r'H:\H-ONUS UTILITY DATA GIS\As_Builts\2014\RandolphPoint_Phase2\RandolphPoint.gdb.gdb'
field = 'Layer'
values = [row[0] for row in arcpy.da.SearchCursor(fc, (field))]
uniqueValues = set(Values)
for value in uniqueValues:
sql = """Layer" = '{0}'""".format(Value)
name = arcpy.ValidateTableName(value,out_gdb)
arcpy.FeatureClassToFeatureClass_conversion(fc, out_gdb, name, sql)
I am trying to convert CAD(dwg) to ArcGIS 10.2.2 Feature Classes using a file geodatase as the workspace. I was just taught this code at an ESRI conference and of course it worked beautifully for the insturtor.
My error I am getting is "NameError:name'Values' is not defined" however I did define it as values = [row[0] for row in arcpy.da.SearchCursor(fc, (field))] I have been working hours on this, it would help out my job considerably.
Python variables are case-sensitive.
You've declared values with a lower-case v, but you're referring to it on the next line with an upper-case V.
(Same with value/Value further down.
import arcpy
fc = r'H:\H-ONUS UTILITY DATA GIS\As_Builts\2014\RandolphPoint_Phase2\789ASBUILT.dwg\Polyline'
out_gdb = r'H:\H-ONUS UTILITY DATA GIS\As_Builts\2014\RandolphPoint_Phase2\RandolphPoint.gdb'
field = 'Layer'
value = [row[0] for row in arcpy.da.SearchCursor(fc, (field))]
uniquevalues = set(value)
for value in uniquevalues:
sql = """"Layer" = '{0}'""".format(value)
name = arcpy.ValidateTableName(value,out_gdb)
arcpy.FeatureClassToFeatureClass_conversion(fc, out_gdb, name, sql)
Here is the solution, I had an extra .gdb in the geodatabase path
my word value was values so had to take the s off
and also in my sql statement I was missing a " before the word Layer
If anyone is reading this just change the individual parameters and it works beautifully!
thanks Juffy for responding and trying to help me out
Cartogal
I'm trying to filter a dataframe for a certain date in a column.
The colum entries are timestamps and I try to construct a boolean vector from those,
checking for a certain date.
I tried:
filterfr = df[((df.expiration.month==6) & (df.expiration.day==22) & (df.expiration.year==2002)]
It doesn't work, because 'Series' object has no attribute 'month'.
How can this be done?
When you do df.expiration, you get back a Series where the items are the expiration datetimes.
Try comparing to an actual datetime.datetime object:
filterfr = df[df['expiration'] == datetime.datetime(2002, 6, 22)]
You may want to look into using a DatetimeIndex, depending on your dataset. This lets you use the convenient syntax
df['2002-06-22']
To have access to the DatetimeIndex methods you have to wrap it in DatetimeIndex (currently*).
The fastest way is to access the day, month and year attributes (just like you attempted):
expir = pd.DatetimeIndex(df['expiration'])
(expir.day == 22) & (expir.month == 6) & (expir.year == 2002)
Alternative, but slower ways are to use the normalize method (to bring it to the start of the day), or to use the date attribute:
pd.DatetimeIndex(df['expiration']).normalize() == datetime.datetime(2002, 06, 22)
pd.DatetimeIndex(df['expiration']).date == datetime.datetime(2002, 06, 22)
*In 0.15 there will be a dt attribute so that you can access these as:
expir = df['expiration']
expir.dt.day ...
This
filterfr = df[df['expiration'] == datetime.datetime(2002, 6, 22)]
worked fine.
However, after doing some filtering, I got an error,
when trying to do filterfr.expiration[0]
or filterfr['expiration'][0]
to get the first element in the series.
KeyError: 0L is raised, although there are elements in the series.
The series looks like this:
Name: expiration, Length: 534668, dtype: datetime64[ns]
Shouldn't this actually always work?
I have an UltraGrid in my Windows Form Application and it has to have two bands. I was able to setup the Parent Band with no problem by using the code below:
Try
con.Open()
da = New SqlDataAdapter("SELECT o.OJTID, o.Surname + ', ' + o.FirstName + ' ' + o.MiddleName AS FullName, t.TotalGrade FROM tblOJTs o INNER JOIN tblTGrades t ON o.OJTID = t.OJTID", con)
da.Fill(ds, "tblOGrades")
con.Close()
Catch ex As Exception
MsgBox("Error connecting to databe.", MsgBoxStyle.Critical)
MsgBox(ex.ToString)
con.Close()
Exit Sub
End Try
UltraGrid1.DisplayLayout.ViewStyle = Infragistics.Win.UltraWinGrid.ViewStyle.MultiBand
UltraGrid1.DataSource = ds.Tables("tblOGrades")
The thing now is, I dont know how to set the datasource of the Child Band. I dont encounter such problem with UltraWebGrid because of the Hierarchical DataSource feature but I think its not available for WinForms. I know you guys will help thanks in advance :)
You need to fill another DataTable in your DataSet with the data related to the first table. After that, you should define the relation between the two datables and finally set the DataSource of the UltraWinGrid to the DataSet itself instead of the single DataTable.
For example:
con.Open()
da = New SqlDataAdapter("SELECT o.OJTID, o.Surname ....", con)
da.Fill(ds, "tblOGrades")
da = new SqlDataAdapter("SELECT .related data....", con)
da.Fill(ds, "tblRelated")
ds.Relations.Add("Grades_Relation", _
ds.Tables("tblOGrades").Columns("OJTID"), _
ds.Tables("tblRelated").Columns("relatedID"))
con.Close()
....
UltraGrid1.DataSource = ds