Page 1 of 1

Title Status Set to Blank

Posted: Mon Jul 17, 2023 11:51 am
by nickparker-hsoa
We are trying to set the Title Stauts to blank if the order status is set to canceled. Please see below rule and let me know if there is an option to be able to set this to blank:

def Title_Status_Value(args):
o = args.Context.Root
oTCA = ['TO','TE']
oTC = o.Type.Code
iT = o.IsTemplate
oS = o.Status
oSCA = OrderStatus.Canceled
oSDU = OrderStatus.Duplicate
tSI = TitleStatus.InProcess
tSCA = TitleStatus.Canceled

exemptProfiles = ['NULL']
profilePath = o.OwnershipProfile.Path

for profile in exemptProfiles:
if profile not in profilePath:
if not iT and oTC in oTCA and oS != oSCA:
args.Value = tSI
elif not iT and oTC in oTCA and oS == oSCA:
args.Value = tSCA
elif not iT and oTC in oTCA and oS == oSDU:
args.Value == None
else:
args.RunDefaultRule()
else:
args.RunDefaultRule()

Re: Title Status Set to Blank

Posted: Mon Jul 17, 2023 5:03 pm
by BobRichards
Please repost the Python code inside of "Code" tags to perserve the whitespace. You can enter these tags by pressing the
Code.jpg
Code.jpg (1.08 KiB) Viewed 5107 times
button in the ribbon above the text entry box.

Re: Title Status Set to Blank

Posted: Wed Jul 19, 2023 8:30 am
by nickparker-hsoa

Code: Select all

def Title_Status_Value(args):
	o = args.Context.Root
	oTCA = ['TO','TE']
	oTC = o.Type.Code
	iT = o.IsTemplate
	oS = o.Status
	oSCA = OrderStatus.Canceled
	oSDU = OrderStatus.Duplicate
	tSI = TitleStatus.InProcess
	tSCA = TitleStatus.Canceled
	
	exemptProfiles = ['NULL']
	profilePath = o.OwnershipProfile.Path
	
	for profile in exemptProfiles:
		if profile not in profilePath:
			if not iT and oTC in oTCA and oS != oSCA:
				args.Value = tSI
			elif not iT and oTC in oTCA and oS == oSCA:
				args.Value = tSCA
			elif not iT and oTC in oTCA and oS == oSDU:
				args.Value == None
			else:
				args.RunDefaultRule()
		else:
			args.RunDefaultRule()

Re: Title Status Set to Blank

Posted: Wed Jul 19, 2023 5:22 pm
by PaulMcCullough
You can use TitleStatus.None for the "blank" value. I tested this version of the rule. When I set the order status to Canceled, the Title Status is set to the "blank" value.

Code: Select all

def Title_Status_Value(args):
    o = args.Context.Root
    oTCA = ['TO','TE']
    oTC = o.Type.Code
    iT = o.IsTemplate
    oS = o.Status
    oSCA = OrderStatus.Canceled
    oSDU = OrderStatus.Duplicate
    tSI = TitleStatus.InProcess
    tSCA = TitleStatus.Canceled
    tSN = TitleStatus.None

    exemptProfiles = ['NULL']
    profilePath = o.OwnershipProfile.Path

    for profile in exemptProfiles:
        if profile not in profilePath:
            if not iT and oTC in oTCA and oS != oSCA:
                args.Value = tSI
            elif not iT and oTC in oTCA and oS == oSCA:
                args.Value = tSN
            elif not iT and oTC in oTCA and oS == oSDU:
                args.Value == None
            else:
                args.RunDefaultRule()
        else:
            args.RunDefaultRule()

Re: Title Status Set to Blank

Posted: Thu Jul 20, 2023 9:06 am
by nickparker-hsoa
This worked for cancelled so I thought I could just use the same thing for when the order status is set to duplicate but the title status stays as in process.

Code: Select all

def Title_Status_Value(args):
	o = args.Context.Root
	oTCA = ['TO','TE']
	oTC = o.Type.Code
	iT = o.IsTemplate
	oS = o.Status
	oSCA = OrderStatus.Canceled
	oSDU = OrderStatus.Duplicate
	tSI = TitleStatus.InProcess
	tSCA = TitleStatus.Canceled
	tSN = TitleStatus.None
	
	exemptProfiles = ['NULL']
	profilePath = o.OwnershipProfile.Path
	
	for profile in exemptProfiles:
		if profile not in profilePath:
			if not iT and oTC in oTCA and oS != oSCA:
				args.Value = tSI
			elif not iT and oTC in oTCA and oS == oSCA:
				args.Value = tSN
			elif not iT and oTC in oTCA and oS == oSDU:
				args.Value = tSN
			else:
				args.RunDefaultRule()
		else:
			args.RunDefaultRule()

Re: Title Status Set to Blank

Posted: Thu Jul 20, 2023 10:34 am
by PaulMcCullough
The first if statement is grabbing everything where the order status is not Canceled. That means if the order status is Duplicate, it will fall into the first if statement. Reordering your if statements and removing the check for oS != oSCA should do the trick. Here is a snippet you can try.

Code: Select all

	for profile in exemptProfiles:
		if profile not in profilePath:
			if not iT and oTC in oTCA and oS == oSCA:
				args.Value = tSN
			elif not iT and oTC in oTCA and oS == oSDU:
				args.Value = tSN
			elif not iT and oTC in oTCA:
				args.Value = tSI
			else:
				args.RunDefaultRule()
		else:
			args.RunDefaultRule()
You could also move the conditions that you check on every if statement into one if statement, then setting Title Status to InProcess becomes just an else statement.

Code: Select all

	for profile in exemptProfiles:
		if profile not in profilePath and not iT and oTC in oTCA:
			if oS == oSCA:
				args.Value = tSN
			elif oS == oSDU:
				args.Value = tSN
			else:
				args.Value = tSI
		else:
			args.RunDefaultRule()